@@ -562,8 +562,8 @@ Public bound method:
562
562
* ` __call__ ` This returns the coro and is used to schedule the task using the
563
563
event loop ` create_task() ` method using function call syntax.
564
564
565
- The ` StopTask ` exception is an alias for ` usayncio.CancelledError ` . In my view
566
- the name is more descriptive of its function.
565
+ The ` asyn. StopTask` exception is an alias for ` usayncio.CancelledError ` . In my
566
+ view the name is more descriptive of its function.
567
567
568
568
### 4.2.1 Groups
569
569
@@ -579,12 +579,12 @@ A task created with the `cancellable` decorator can intercept the `StopTask`
579
579
exception to perform custom cleanup operations. This may be done as below:
580
580
581
581
``` python
582
- @cancellable
582
+ @asyn. cancellable
583
583
async def foo ():
584
584
while True :
585
585
try :
586
586
await sleep(1 ) # Main body of task
587
- except StopTask:
587
+ except asyn. StopTask:
588
588
# perform custom cleanup
589
589
return # Respond by quitting
590
590
```
@@ -593,11 +593,11 @@ The following example returns `True` if it ends normally or `False` if
593
593
cancelled.
594
594
595
595
``` python
596
- @cancellable
596
+ @asyn. cancellable
597
597
async def bar ():
598
598
try :
599
599
await sleep(1 ) # Main body of task
600
- except StopTask:
600
+ except asyn. StopTask:
601
601
return False
602
602
else :
603
603
return True
@@ -697,11 +697,11 @@ if necessary. This might be done for cleanup or to return a 'cancelled' status.
697
697
The coro should have the following form:
698
698
699
699
``` python
700
- @cancellable
700
+ @asyn. cancellable
701
701
async def foo ():
702
702
try :
703
703
await asyncio.sleep(1 ) # User code here
704
- except StopTask:
704
+ except asyn. StopTask:
705
705
return False # Cleanup code
706
706
else :
707
707
return True # Normal exit
@@ -716,7 +716,7 @@ latest API changes are:
716
716
* ` NamedTask.cancel() ` is now asynchronous.
717
717
* ` NamedTask ` and ` Cancellable ` coros no longer receive a ` TaskId ` instance as
718
718
their 1st arg.
719
- * ` @namedtask ` still works but is now an alias for ` @cancellable ` .
719
+ * ` @asyn. namedtask ` still works but is now an alias for ` @asyn. cancellable ` .
720
720
721
721
The drive to simplify code comes from the fact that ` uasyncio ` is itself under
722
722
development. Tracking changes is an inevitable headache.
0 commit comments