New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The cherrypy.engine can't handle DummyThreads on Python 3.4 #1342
Comments
Original comment by Lindsay Stevens (Bitbucket: lindsay-stevens-kirby, GitHub: @lindsay-stevens): I have come across the same kind of problem, but have a different solution. I am using Windows 7 x64 with Python 3.5.1, Cherrypy 4.0.0. The same issue will occur whether cherrypy is run from the console and inside of a service. In a clean virtualenv, the problem does not appear until pywin32 is installed. It happens with both the Pypi "pypiwin32-219" wheel, and the "pywin32-220" wheel from http://www.lfd.uci.edu/~gohlke/pythonlibs. Steps to reproduce:
These are the commands to set it up, if your Windows is rusty.
If it doesn't happen the first time, start the server then try kicking off some threads by opening a browser and hitting 127.0.0.1:8080 a few times. The problem goes away if the t.isAlive() check mentioned in the Traceback is removed, as follows:
This check to see if the thread is alive is not needed anyway, since from Python 2.6 to 3.5 [1], [2], the docs note that "The module function enumerate() returns a list of all alive threads". The objects being evaluated are from the enumerate call on line 325. After making this change, the same sequence of steps results in successful shutdown, with the final log message "ENGINE Bus EXITED". [1] https://docs.python.org/2.6/library/threading.html#threading.Thread.is_alive [2] https://docs.python.org/3.5/library/threading.html#threading.Thread.is_alive |
Btw, @cyraxjoe did you finish your pdb plugin? |
@lindsay-stevens thanks for your investigation, it has helped to solve the original issue recently :) |
Originally reported by: Joel Rivera (Bitbucket: cyraxjoe, GitHub: cyraxjoe)
I'm making a plugin to integrate Winpdb to CherryPy and I was having an issue with threads half-stopped on the
block
method of thecherrypy.engine
(wspb
) and it turns out that the problem is with a fix on cpython which set the_stop
method body aspass
and therefore never executing the expected method of thethreading.Thread
.In particular this method sets the property:
_is_stopped
toTrue
and because of that, the methodthreading.Thread.isAlive
is unusable on the_DummyThread
instances on Python 3.4. The problem was introduced after fixing the Issue 18808 of cpython the added a call to a new method _wait_for_tstate_loc that makes an assertion to the_is_stopped
property and therefore ending with anAssertionError
when thecherrypy.engine.block
method reach the isAlive call.After the
isAlive
call on theblock
method there is a comment which states:And indeed is true, but the
AssertionError
gets raised before reaching that line on Python 3.4.This is an example of the resulting traceback:
I suggest that we can change the
isinstance
validation of the_MainThread
to:And set it before the
isAlive
call on theif
conditional expression:This is valid from python 2.4 up to 3.4.
I can make this change, but I'm looking on a second opinion on this issue.
The text was updated successfully, but these errors were encountered: