Created
July 24, 2020 08:03
-
-
Save JustusAdam/3e5c7b2b0f04d32ccdf85930d47441d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interrupt_handler = lambda _: None | |
def foo(): | |
global interrupt_handler | |
# also could be something like write to a channel, opened only locally in foo | |
def h(x): | |
print(x) | |
interrupt_handler = h | |
for i in bar(): | |
print(i) | |
def bar(): | |
yield 4 | |
yield 3 | |
baz() | |
yield 1 | |
def baz(): | |
# somehow force bar to `yield` | |
# or `return` 2 | |
interrupt_handler(2) | |
print(foo()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment