From: Geoff T. <gta...@na...> - 2000-12-07 21:48:36
|
It looks to me that on Linux, Ctrl-C can trigger an exception in ANY thread, not just the main thread. I think this might make it impossible to handle Ctrl-C safely in ThreadedAppServer on Linux. I've already developed a fix for Windows NT, but it might do no good on Linux. Should I check it in anyway? Tom Schwaller wrote: > Geoff Talvola wrote: > > > > I've identified a problem with Ctrl-C handling in ThreadedAppServer such > > that it can sometimes fail to shut down and needs to be killed. The > > reason is that Ctrl-C causes the main Python thread to immediately throw > > an exception, wherever it may be in the code. If you happen to press > > Ctrl-C while the main thread is blocking, waiting to put something into > > the request queue, then the queue gets into a state where it blocks > > indefinitely the next time you try to put something into the queue. > > > > Here's a test program that illustrates the problem. I've tried it on NT > > with Python 1.5.2. If I run it with argument 0, it never exits when I > > press Ctrl-C and has to be killed. But if I run it with argument 1, it > > works fine because it puts the Queue manipulation into a separate thread > > -- this would be a way to fix ThreadedAppServer. > > > > If someone could run it on Linux and let me know if you get the same > > results, I'd appreciate it. > > Under Linux I have to kill them in BOTH cases. Your > prediction does not seem to work.. > > Exception in thread Thread-3: > Traceback (innermost last): > File "/usr/lib/python1.5/threading.py", line 376, in __bootstrap > self.run() > File "/usr/lib/python1.5/threading.py", line 364, in run > apply(self.__target, self.__args, self.__kwargs) > File "testthreads.py", line 8, in threadfunc > time.sleep(1.0) > IOError: [Errno 4] Unterbrechung während des Betriebssystemaufrufs > > Exception in thread Thread-4: > Traceback (innermost last): > File "/usr/lib/python1.5/threading.py", line 376, in __bootstrap > self.run() > File "/usr/lib/python1.5/threading.py", line 364, in run > apply(self.__target, self.__args, self.__kwargs) > File "testthreads.py", line 8, in threadfunc > time.sleep(1.0) > IOError: [Errno 4] Unterbrechung während des Betriebssystemaufrufs > > Ignore the German Error messages. ... Means "interrupt during system > call" ... > > -- > > Tom Schwaller > http://www.linux-community.de > http://www.linux-magazin.de/ -- - Geoff Talvola Parlance Corporation gtalvola@NameConnector.com |