Jacek Popławski wrote: > Hello. > > I am going to write python script which will read python command from > socket, run it and return some values back to 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. > > How can I implement my script then? > > PS. it should be portable - Linux, Windows, QNX, etc
Probably the easiest way is to use select with a timeout (see the docs for library module select). eg. a, b c = select.select([mySocket], [], [], timeout) if len(a) == 0: print 'We timed out' else: print 'the socket has something for us' Steve -- http://mail.python.org/mailman/listinfo/python-list