Created
September 18, 2020 16:12
-
-
Save fabiocerqueira/5c7926e2577bd6e8795e0e4e50a7453c to your computer and use it in GitHub Desktop.
never raise or return on finally blocks (in Python also continue will break things)
This file contains hidden or 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
from twisted.internet import defer, reactor, threads | |
@defer.inlineCallbacks | |
def problem(): | |
1 / 0 | |
yield 1 | |
@defer.inlineCallbacks | |
def nice_bug(): | |
try: | |
yield problem() | |
except Exception as e: | |
raise e | |
finally: | |
print("where is my expection? hahah") | |
defer.returnValue(None) | |
@defer.inlineCallbacks | |
def main(): | |
yield nice_bug() | |
reactor.stop() | |
if __name__ == "__main__": | |
reactor.callLater(0, main) | |
reactor.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment