Skip to content

Commit

Permalink
Merge pull request #2811 from rmartin16/gen-handler-always-sleep
Browse files Browse the repository at this point in the history
Always sleep between iterations of generator handlers
  • Loading branch information
freakboy3742 authored Sep 4, 2024
2 parents cc849f8 + 8284666 commit fb5add4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/2811.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When a handler is a generator, control will now always be released to the event loop between iterations, even if no sleep interval or a sleep interval of 0 is yielded.
3 changes: 1 addition & 2 deletions core/src/toga/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ async def long_running_task(
try:
while True:
delay = next(generator)
if delay:
await asyncio.sleep(delay)
await asyncio.sleep(delay if delay else 0)
except StopIteration as e:
result = e.value
except Exception as e:
Expand Down

0 comments on commit fb5add4

Please sign in to comment.