Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Global:
- killed = False
- @app.route('/test1')
- def test1():
- # Kill all other similar processes before running this process
- Global.killed = True
- time.sleep(1) # wait a while to be sure the other threads see that Global.killed ==True
- Global.killed = False
- # Run a mock process that takes some time
- a = 100
- while a >= 0:
- time.sleep(0.1)
- a -= 1
- print('koe', a)
- if Global.killed:
- print('killed!')
- break
- print('done!')
- @app.route('/kill')
- def kill():
- Global.killed = True
- return 'killed'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement