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

Swallow Python exceptions better on workflow GC from eviction #341

Merged
merged 4 commits into from
Jul 11, 2023

Conversation

cretz
Copy link
Member

@cretz cretz commented Jul 10, 2023

What was changed

Python raises GeneratorExit when GC'ing coroutines that are being awaited on. So when our workflow is evicted, users were seeing uncaught exception warnings. Also, if they had finally logic that did something with the workflow, the event loop is already unset so that error is raised too, causing Python warning, sometimes swallowing GeneratorExit (which causes another type of Python exception).

This no longer logs GeneratorExit or no-workflow-runtime exceptions when deleting, and all other exceptions during delete are just logged at the debug level

Checklist

  1. Closes [Bug] GeneratorExit inadvertently caught, and also core timer mismatch  #325

@cretz cretz requested a review from a team as a code owner July 10, 2023 18:00
Comment on lines +659 to +660
logger.debug(
"Ignoring exception while deleting workflow", exc_info=True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nit but IMO this is more like trace level

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was a tough call, but figured since I remove the two primary cases where this happens, the rest I think are fairly rare. And in fact, this can show a sign of a code smell, because it might mean you are swallowing an exception in a finally if it's not one of these two exception types.

@cretz cretz mentioned this pull request Jul 10, 2023
1 task
@cretz cretz merged commit b902ec8 into temporalio:main Jul 11, 2023
12 checks passed
@cretz cretz deleted the generator-exit branch July 11, 2023 19:19
@cretz cretz mentioned this pull request Apr 2, 2024
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 this pull request may close these issues.

[Bug] GeneratorExit inadvertently caught, and also core timer mismatch
2 participants