-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from MaineKuehn/activity-api
Activity api
- Loading branch information
Showing
13 changed files
with
412 additions
and
252 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
Interlude 01: Interrupting Scopes | ||
--------------------------------- | ||
|
||
.. code:: python3 | ||
>>> from usim import time, until | ||
>>> | ||
>>> async def deliver_one(which): | ||
... print('Delivering', which, 'at', time.now) | ||
... await (time + 5) | ||
... print('Delivered', which, 'at', time.now) | ||
>>> | ||
>>> async def deliver_all(count=3): | ||
... print('-- Start deliveries at', time.now) | ||
... async with until(time + 10) as deliveries: # 1 | ||
... for delivery in range(count): # 2 | ||
... deliveries.do(deliver_one(delivery)) | ||
... await (time + 3) | ||
... print('Sent deliveries at', time.now) # 4.1 | ||
... print('-- Done deliveries at', time.now) # 4.2 |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.