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

RuntimeError: can't register atexit after shutdown #204

Open
jaguar36 opened this issue May 4, 2022 · 8 comments
Open

RuntimeError: can't register atexit after shutdown #204

jaguar36 opened this issue May 4, 2022 · 8 comments

Comments

@jaguar36
Copy link

jaguar36 commented May 4, 2022

When running a simple vpython script, as I move the mouse across the screen I get a continual stream of these errors:

Task exception was never retrieved
future: <Task finished name='Task-2435' coro=<WSserver.onMessage() done, defined at C:\Users\kg604c\AppData\Roaming\Python\Python310\site-packages\vpython\no_notebook.py:181> exception=RuntimeError("can't register atexit after shutdown")>
Traceback (most recent call last):
  File "C:\Users\kg604c\AppData\Roaming\Python\Python310\site-packages\vpython\no_notebook.py", line 214, in onMessage
    await loop.run_in_executor(None, GW.handle_msg, msg)
  File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 808, in run_in_executor
    executor = concurrent.futures.ThreadPoolExecutor(
  File "C:\Program Files\Python310\lib\concurrent\futures\__init__.py", line 49, in __getattr__
    from .thread import ThreadPoolExecutor as te
  File "C:\Program Files\Python310\lib\concurrent\futures\thread.py", line 37, in <module>
    threading._register_atexit(_python_exit)
  File "C:\Program Files\Python310\lib\threading.py", line 1484, in _register_atexit
    raise RuntimeError("can't register atexit after shutdown")
RuntimeError: can't register atexit after shutdown

This seems to be the same issue as mentioned in #133 however that was a few years ago. I'm unable to downgrade to an older version of python though, is it still something that hasn't been fixed?

I'm running Python 3.10.0 and VPython 7.6.3

@BruceSherwood
Copy link
Member

Never having seen this bug, what platform are you using? What is the "simple" program that triggers the error?

@jaguar36
Copy link
Author

jaguar36 commented May 5, 2022

Windows 10 version 20H2, on either Firefox or Edge.

from vpython import *

box()

@jaguar36
Copy link
Author

jaguar36 commented May 9, 2022

bump
Anyone have any suggestions? I've tried updating all the other modules that Vpython seems to use but am still getting this error.

I'm still able to manipulate the view, however widgets and buttons don't work.

@BruceSherwood
Copy link
Member

I happen to be running VPython 7.6.3 with Python 3.9.7, so I will update to 3.10 to see if I can reproduce the error. Thanks for the info.

@jaguar36
Copy link
Author

I was able to find another install on the same PC with 3.7 and didn't have any issues with it. That was using a different set of modules though so I'm not sure if it is soley 3.10 that is the issue. Also seems odd that the previous poster had the same issue with 3.9 in 2020 but you said it works fine on 3.9 now.

@BruceSherwood
Copy link
Member

John Coady posted the following to the VPython forum, which looks relevant:

The fix is to install an older version of autobahn package and txaio. The steps to fix are to uninstall autobahn and txaio

conda uninstall autobahn
conda uninstall txaio

or

pip uninstall autobahn
pip uninstall txaio

Then install autobahn version 21.11.1

pip install autobahn==21.11.1

and this will install txaio version 22.2.1

These were the versions of autobahn and txaio that existed when vpython 7.6.3 came out.

Vpython should probably create a new release to fix this problem or to use older versions of autobahn and txaio as dependencies.

John

@jaguar36
Copy link
Author

I tried that, but it unfortunately it didn't fix it.
I also tried uninstalling all of my python modules listed by pip freeze, and then reinstalling Vpython. This gave me the error about not calling .use_twisted. Going back to the old version of autobahn fixed that.

I did add this based on another comment:

while True:
    pass

and that seems to have fixed it.

Will that cause any other issues?

@BruceSherwood
Copy link
Member

I have no idea why that loop was relevant, but should you ever wish to run in jupyter notebook or jupyter lab or Web VPython I think the display will freeze (I know for sure it will freeze in Web VPython). Instead of "pass" use "rate(100)" or similar statement. It happens that of all the various instantiations of VPython, only the "no-notebook" version uses threads, which means that displays can be updated (associated with mousing, for example).

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

2 participants