Skip to content

Instantly share code, notes, and snippets.

@fabiocerqueira
Created September 18, 2020 16:12
Show Gist options
  • Save fabiocerqueira/5c7926e2577bd6e8795e0e4e50a7453c to your computer and use it in GitHub Desktop.
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)
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