Skip to content
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

Inexplicable yet reproducible hang with thread that continues after exit from embedding app #547

Open
genovese opened this issue Aug 24, 2023 · 0 comments

Comments

@genovese
Copy link

A few particular commands in a ptpython repl cause an odd behavior in ptpython that seems to be an underlying threading problem. The commands are reproducible yet have nothing apparent that would cause anything unusual. In fact, it's just constructing an object and looking at one its properties. Here's what happends

x = A(4, 5) # A.__init__ just sets props; nothing else, but it always happens with A not B.
x.prop # Just reading the prop that was just set; same happens if not printed, just assigned y = x.prop
# Long hang here, keyboard interrupt ends the hang, and the session continues
... # No problems here
quit()
The repl quits but the shell does not resume, and soon after the computer fan goes nuts with Python is using more CPU.
Another keyboard interrupt, and we see the following, after which the shell resumes and the computer quiets.

^CException ignored in: <module 'threading' from '/usr/local/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py'>
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1537, in _shutdown
    atexit_call()
  File "/usr/local/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/thread.py", line 31, in _python_exit
    t.join()
  File "/usr/local/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1096, in join
    self._wait_for_tstate_lock()
  File "/usr/local/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1116, in _wait_for_tstate_lock
    if lock.acquire(block, timeout):
KeyboardInterrupt:
^C

I'm baffled by this because my code is doing nothing basically. Yet it's the same A() that causes the hang every time...
Note that this does not occur in a standard Python repl, even with the same code. Something with the event loop? Thread handling? I'm wondering if this is related to #541.

Running on Mac OS X 12.6.1; Python 3.10 installed from homebrew.

I'm happy to answer any questions and would really appreciate any pointers on where to look or how to figure out what's happening. I've got people using the app/repl and would like to avoid random hangs.

Thanks (for your help and for ptpython)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant