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

ValueError: signal only works in main thread of the main interpreter #257

Closed
joaander opened this issue Jun 19, 2023 · 0 comments · Fixed by #258
Closed

ValueError: signal only works in main thread of the main interpreter #257

joaander opened this issue Jun 19, 2023 · 0 comments · Fixed by #258
Labels
bug Something isn't working

Comments

@joaander
Copy link
Member

Description

ValueError: signal only works in main thread of the main interpreter when importing gsd in a non-main thread.

Script

import threading

def test():
    import gsd

thread = threading.Thread(target=test)
thread.start()
thread.join()

Input files

No response

Output

Exception in thread Thread-1 (test):
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/joaander/test/test-gsd-thread.py", line 4, in test
    import gsd
  File "/Users/joaander/venv/lib/python3.11/site-packages/gsd/__init__.py", line 21, in <module>
    signal.signal(signal.SIGTERM, lambda n, f: sys.exit(1))
  File "/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/signal.py", line 56, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: signal only works in main thread of the main interpreter

Expected output

none

Platform

Linux, macOS

Installation method

PyPI package

GSD

3.0.0

Python version

3.11.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant