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

BUG: library defines signal handler without calling previously set handlers #9

Open
solderdev opened this issue Mar 6, 2024 · 0 comments

Comments

@solderdev
Copy link

Hi!

In board.py --> class Board --> __init__() (line 1329) a signal handler is added.
This overwrites previously defined signal handlers.
Additionally, because of this the init function may only be called in the main thread of the application.

solutions:
a)
Define a "stop()" method and do cleanup there. Best solution.

b)
When adding a signal handler with signal.signal() the old handler is returned.
Save it and call it later like this:

class Board:
  def __init__(self):
    self.prev_handler = signal.signal(signal.SIGINT, self._exit_handler)
  def _exit_handler(self, signum, frame):
    print("exit_handler")
    # do cleanup
    self.prev_handler(signum, frame)

Thank you and best regards

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