Advertisement
Guest User

Untitled

a guest
Jul 9th, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. timeout = 5
  2. sub = Thread(target = lambda: download("http://......."))
  3. sub.start()
  4.  
  5. while sub.isAlive() and timeout > 0:
  6.     sleep(1)
  7.     timeout -= 1
  8.  
  9. if sub.isAlive():
  10.     raise Error[/code]
  11.  
  12.  
  13. The download(...) function wasn't written by me and it's infinitely blocking if it can't reach the destination so I'm trying to forcefully terminate it after 5 seconds.
  14. Why isn't this working? Python btw.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement