[issue29988] (async) with blocks and try/finally are not as KeyboardInterrupt-safe as one might like

Nick Coghlan report at bugs.python.org
Wed Apr 5 01:46:12 EDT 2017


Nick Coghlan added the comment:

My first thought would be to inject a wordcode instruction that's essentially an eval loop directive: "ATOMIC_UNTIL <offset>"

ATOMIC_UNTIL would have at least the following properties:

- checks for signals are skipped until the given offset is reached
- checks to release the GIL are skipped until the given offset is reached

It may also have the following defensive coding property:

- only wordcode instructions on a pre-approved whitelist are permitted during atomic execution blocks (i.e. we'd only add them to the whitelist on an as needed basis, to minimise the risk of undesirable side effects, like being able to use wordcode manipulation to put an entire loop inside an atomic block)

The last bit would likely have undesirable performance implications, so it would probably be reasonable to only enable the check for debug builds, rather than always enforcing it.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29988>
_______________________________________


More information about the Python-bugs-list mailing list