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

Consider using Cysignals #298

Closed
LasseBlaauwbroek opened this issue Sep 16, 2022 · 1 comment · Fixed by #313
Closed

Consider using Cysignals #298

LasseBlaauwbroek opened this issue Sep 16, 2022 · 1 comment · Fixed by #313

Comments

@LasseBlaauwbroek
Copy link
Contributor

As described in capnproto/capnproto#1542, Pycapnp is having issues with catching signals while executing long-running capnp C++ code, because Python's signal handlers are only executed outside of external code.

Other libraries also seem to have this issue, hence the existence of cysignals. I propose that any possibly-long-running C++ code (particularly blocking C++ code) is wrapped in

    from cysignals.signals cimport sig_on, sig_off
    sig_on()
    try:
        # C++ code
    finally:
        sig_off()
@kentonv
Copy link
Member

kentonv commented Sep 16, 2022

Unfortunately I don't think this is so simple. sig_on() apparently uses setjmp() and then the signal handler longjmp()s back to it. This only really works if the C++ code has not done any RAII initialization before the longjmp(). Otherwise, all the necessary cleanup will be skipped. This would lead to a lot of problems when calling into Cap'n Proto / KJ code.

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

Successfully merging a pull request may close this issue.

2 participants