August 4th, 2005, 04:31 PM
To get thread id and ask it to stop cleanly
Well I am using threading.Thread.
In my application there will be at some time multiple threads will be running. Now if user tries to close the application than at that moment I just want to implement following:
1.0 Check are there some active worker threads
2.0 If yes then prompt to user Messagebox that already threads are running do you still want to close application
3.0 If user tells yes then just get all active thread one by one and try to stop them cleanly
4.0 I have to take care that socket which is created in my code is also closed
# Run function of thread
self.socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
# Do something here
How to do this? Any ideas and suggestions...
August 4th, 2005, 05:21 PM
Look into the register() function of the atexit module. The threading module not only has the Timer() function will you will be able to use (and can cancel at any given time), but it has a function for retrieving any threads (processes) still currently running. So you will have to also look into that function to learn more. As for the message box, I would go with Tkinter for getting that done correctly.