killing thread after timeout
Peter Hansen
peter at engcorp.com
Tue Sep 6 15:19:30 EDT 2005
Jacek Popławski wrote:
> I am going to write python script which will read python command from
> socket, run it and return some values back to socket.
(Sounds like a huge security risk, unless you have tight control over
who can connect to that socket.)
> My problem is, that I need some timeout. I need to say for example:
>
> os.system("someapplication.exe")
>
> and kill it, if it waits longer than let's say 100 seconds
>
> I want to call command on separate thread, then after given timeout -
> kill thread, but I realized (after reading Usenet archive) that there is
> no way to kill a thread in Python.
The issue isn't killing a thread in Python, it's killing the *new
process* which that thread has started. To do that you have to rely on
OS-specific (i.e. non-portable) techniques. Googling for "python kill
process" would probably get you off to a good start.
-Peter
More information about the Python-list
mailing list