-
Notifications
You must be signed in to change notification settings - Fork 124
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
1.1.0 causes multiprocessing workers to hang on exit #255
Comments
Using
Looking at the threads and their
PS: As stated above calling |
Ah, great, thanks for the info and quick workaround! I didn't know where to even start debugging twisted + multiprocessing. I can confirm that shutdown() lets it exit cleanly for me here, too. I thought it was weird that join() still succeeded, makes sense now. It's curious that 1.0.0 doesn't exhibit this behaviour, I've run 100s of tests and it's been consistent, so I'd guess not a race or similar. It's beyond my ability to diagnose, so I'll leave that up to you. Possibly docstring for api.connect() could mention shutdown() as being wise to call before attempting to exit? I don't know if that's an appropriate place - I would have seen it, but who knows if I'm typical. Maybe the api object could be made into a context manager too, then there's an obvious place to automatically call shutdown(), though you'd have to nest two contexts just to get a client which is kind of ugly. Since nobody is using api as a context manager currently it shouldn't break existing code.
I don't love it, but I guess it's not terrible looking. Less likely to be appropriate, shutdown() could implicitly occur on leaving the context manager block for the connect()? Perhaps that's too surprising a side effect, since it's the client that leaves scope, not the api. More likely to break existing code. Possibly, use atexit: https://docs.python.org/3/library/atexit.html |
Sadly for me, vncdotool.api.shutdown() doesn't help me in the larger code I was working on. Perhaps I found two different hang bugs. I'll try and work up another clean repro case. |
Found my mistake: in the more complex code, I had multiple processes each handling a VNC connection. I'd missed adding api.shutdown() to one exit route. Your workaround is still effective. |
Possible regression from 1.0.0, it seems that 1.1.0 doesn't let multiprocessing workers exit (even though they join). This means the main script also refuses to exit. Only tested on Linux (Debian Bullseye, and Fedora 37, identical behaviour).
I don't have much experience with vncdotool, multiprocessing or twisted, so I could easily be missing something obvious here. I do have a simple repro script though so it's hopefully easy to test. I tested in a venv with only these listed by freeze:
I didn't control for system packages, please let me know if that's relevant.
vncdotool version
1.1.0
VNC server and version
None required.
Steps to reproduce
Make a python3 venv, install vncdotool 1.1.0. Run the following repro script, it will fail to exit. Or fail to repro, let's find out :)
Downgrade to 1.0.0 and it should exit.
Expected result
Above repro script should exit.
Which erroneous result did you get instead
Script hangs just after final print statement.
Additional information
Possibly related to #188
But that lists using spawn start method as a workaround, and that doesn't help me.
The text was updated successfully, but these errors were encountered: