Killing a thread
Donn Cave
donn at u.washington.edu
Mon Jul 19 13:18:27 EDT 1999
More information about the Python-list mailing list
Mon Jul 19 13:18:27 EDT 1999
- Previous message (by thread): Killing a thread
- Next message (by thread): Killing a thread
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
catlee at my-deja.com writes: | I'm writing a progrma where some user code is executed in a restricted | environment running in a separate thread. Now, if the user is | malicious, s/he can just put 'while 1: 1+1'. I'd like to be able to | recover from this. Is there any way I can kill the thread that is stuck | in the infinite loop? Python's thread support is evolving. As a previous followup points out, you shouldn't kill threads, and I guess that's fair enough - in terms of normal program design, one should look for other ways to manage threads. But in default of any alternative, I suspect sometimes we have to violate this commandment, and I think one of these days Python will provide the tools to do what you have to do, not just what you want to do. At the moment though, it looks to me like you have to go outside Python's thread support. For example on BeOS (happens to be the only OS where I've played with threads), I find I can kill a thread with os.kill(bad_thread_id, 21) (SIGKILLTHR == 21) The thread doesn't clean up normally, but it stops. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu
- Previous message (by thread): Killing a thread
- Next message (by thread): Killing a thread
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list