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

Remove old states in @swim if runner has stopped #175

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove old states in @swim if runner has stopped
  • Loading branch information
thegamecracks committed Mar 7, 2023
commit 36e91f0a49683f7e95a783d7a56c8202788cc646
5 changes: 5 additions & 0 deletions sardine/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ def decorator(func: Union[Callable, AsyncRunner]) -> AsyncRunner:
runner = bowl.scheduler.get_runner(func.__name__)
if runner is None:
runner = AsyncRunner(func.__name__)
elif not runner.is_running():
# Runner has likely stopped swimming, in which case
# we should make sure the old state doesn't pollute
# the new function when it's pushed
runner.reset_states()

# Runners normally allow the same functions to appear in the stack,
# but we will treat repeat functions as just reloading the runner
Expand Down