Re: Killing worker threads
On Jan 6, 7:48 am, Fredrik Lundh [EMAIL PROTECTED] wrote: tarun wrote: Can anyone help me with a simple code through which the main thread can kill the worker thread it started. it cannot. threads cannot be killed from the outside. /F The only way to kill a thread is to have the spawned thread have some kind of passed in argument which will trigger it to shut down. You could have the thread read a file or file-like object periodically (like a timer) and if it meets some condition, have the thread quit. It's kind of like a subscription process. The thread subscribes to the main program and can accept signals. I suggest that the OP read the docs on threads: http://docs.python.org/lib/module-threading.html Of special interest to this user: http://docs.python.org/lib/condition-objects.html I have messed with KillProcName, a PyWin32 script with limited success. There's also the following snippet which is Windows only and works for some processes and not others (i.e. unreliable): subprocess.Popen('taskkill /s %s /im %s' % (computer_id, proc)) Hopefully I didn't muddy the waters or write something too off the mark. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Killing worker threads
maybe following recipe from activestate may be usefull. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496960 http://sebulba.wikispaces.com/recipe+thread2 -- http://mail.python.org/mailman/listinfo/python-list
Killing worker threads
Hello All, Can anyone help me with a simple code through which the main thread can kill the worker thread it started. Thanks Regards, Tarun Devnani -- http://mail.python.org/mailman/listinfo/python-list
Re: Killing worker threads
You can use the stop method! On Jan 6, 2008 2:04 PM, tarun [EMAIL PROTECTED] wrote: Hello All, Can anyone help me with a simple code through which the main thread can kill the worker thread it started. Thanks Regards, Tarun Devnani -- http://mail.python.org/mailman/listinfo/python-list -- http://search.goldwatches.com/?Search=Movado+Watches http://www.jewelerslounge.com http://www.goldwatches.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Killing worker threads
tarun wrote: Can anyone help me with a simple code through which the main thread can kill the worker thread it started. it cannot. threads cannot be killed from the outside. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Killing worker threads
James Matthews wrote: You can use the stop method! You can? import threading t = threading.Thread() t.stop() Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'Thread' object has no attribute 'stop' What Python version are you using? /F -- http://mail.python.org/mailman/listinfo/python-list