From: Alex I. <a_...@ma...> - 2012-10-05 08:29:40
|
Hello! First of all, thank you, Christoph, for the excellent software! I've been using webware since 2002 and have not yet seen a decent replacement to it! Outstanding performance of lightweight servlets implementation leaves behind its competitors with their tons of useless code. That's the main feature I'm using from webware. Upgraded recently to 1.1 and discovered a freeze when I press Ctrl+C. It happens only on Windows. I'm using Windows 7. Linux is not affected. In fact the reason of the freeze seems to be quite simple: ThreadedAppServer.py, line 1308: t = Thread(target=_windowsmainloop) t.start() ... _windowsmainloop calls server.mainloop(), which flags self._running: threadCheckInterval = self._maxServerThreads * 2 threadUpdateDivisor = 5 # grab stat interval threadCheck = 0 ---> self._running = 3 # server is in the main loop now On subsequent check server._running is still 1 because the thread does not have enough time to initialize itself: ---> while server._running > 1: try: sleep(1) # wait for interrupt except Exception: if server._running < 3: raise # shutdown So, we skip waiting and freeze at an endless loop. The fix may be the following: ThreadedAppServer.py, line 1307: # Run the server thread t = Thread(target=_windowsmainloop) t.start() try: ---> # Inserting waiting loop before _running status check. ---> for i in range(30): # wait at most 3 seconds for startup ---> if server._running == 3: ---> break ---> sleep(0.1) while server._running > 1: try: sleep(1) # wait for interrupt except Exception: if server._running < 3: raise # shutdown finally: t.join() Can you please confirm that this fix is applicable? We may throw an exception if wait was not successful. Will it be a good idea to rewrite flags usage with python's events wait/set functionality to be on the safe side? Thank you very much, Mikhail |
From: Christoph Z. <ci...@on...> - 2012-10-07 22:37:59
|
Am 05.10.2012 10:29, schrieb Alex Ivanov: > First of all, thank you, Christoph, for the excellent software! I've > been using webware since 2002 and have not yet seen a decent > replacement to it! Outstanding performance of lightweight servlets > implementation leaves behind its competitors with their tons of > useless code. That's the main feature I'm using from webware. > Upgraded recently to 1.1 and discovered a freeze when I press Ctrl+C. > It happens only on Windows. I'm using Windows 7. Linux is not > affected. In fact the reason of the freeze seems to be quite simple: Thanks for the positive feedback, kudos should go to the authors. Your analysis of the problem and fix look good to me. It's actually a race condition, and in fact most of the time it works on my test machine, but sometimes not. And it's not really a freeze, the server works properly, just doesn't respond to Ctrl-C any more, right? I also agree that a better fix would be to use a condition or event instead of the global flag. I'll work on that and plan to have a bugfix release this month. A couple of issues have already been fixed after 1.1, and I have one or two other open issues that I want to address. If there are other small issues that should be addressed in a bugfix release, let me know. -- Christoph |
From: Christoph Z. <ci...@on...> - 2012-10-08 20:50:56
|
Am 05.10.2012 10:29, schrieb Alex Ivanov: > Can you please confirm that this fix is applicable? > We may throw an exception if wait was not successful. > Will it be a good idea to rewrite flags usage with python's events wait/set functionality to be on the safe side? I have fixed it now in trunk in r8233 with the simplest possible patch. Using events would be probably better, but I want to keep the semantics of the existing flag for backward compatibility. -- Christoph |