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

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Webware-discuss mailing list
Webware-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to