daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2018 184 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Global:
  2.     killed = False
  3.  
  4. @app.route('/test1')
  5. def test1():
  6.     # Kill all other similar processes before running this process
  7.     Global.killed = True
  8.     time.sleep(1) # wait a while to be sure the other threads see that Global.killed ==True
  9.     Global.killed = False
  10.  
  11.     # Run a mock process that takes some time
  12.     a = 100
  13.     while a >= 0:
  14.         time.sleep(0.1)
  15.         a -= 1
  16.         print('koe', a)
  17.         if Global.killed:
  18.             print('killed!')
  19.             break
  20.     print('done!')
  21.  
  22. @app.route('/kill')
  23. def kill():
  24.     Global.killed = True
  25.     return 'killed'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top