Skip to content

Commit e0520b9

Browse files
author
Roberto De Ioris
authored
Update AsyncIOAndUnrealEngine.md
1 parent 120e6df commit e0520b9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tutorials/AsyncIOAndUnrealEngine.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,23 @@ import ue_asyncio
131131
async def simple_timer(frequency):
132132
while True:
133133
await asyncio.sleep(frequency)
134-
ue.log('{0} secondss elapsed'.format(frequency))
134+
ue.log('{0} seconds elapsed'.format(frequency))
135135

136136
asyncio.ensure_future(simple_timer(2))
137137
```
138138

139+
If you run this script in the UE Python console you will start getting messages every 2 seconds.
140+
141+
If you re-run the script, a new coroutine will be spawned, but the old one is still here...
142+
143+
Generally this is not what you want, lucky enouch each asyncio loop allows you to access the list of currently available coroutines, and eventually cancel them:
144+
145+
```python
146+
for task in asyncio.Task.all_tasks():
147+
task.cancel()
148+
```
149+
150+
139151
## asyncio in your actors
140152

141153
## Additional 'transient' loop engines

0 commit comments

Comments
 (0)