File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -821,24 +821,27 @@ The `Task.wait_on` method defines how to block the current task on a given
821
821
Python [ awaitable] using the ` OnBlock ` callback described above:
822
822
``` python
823
823
async def wait_on (self , awaitable , sync , cancellable = False ) -> bool :
824
- awaitable = asyncio.ensure_future(awaitable)
825
- assert (not self .inst.calling_sync_import)
826
824
if sync:
825
+ assert (not self .inst.calling_sync_import)
827
826
self .inst.calling_sync_import = True
828
827
else :
829
828
self .maybe_start_pending_task()
829
+
830
+ awaitable = asyncio.ensure_future(awaitable)
830
831
cancelled = await self .on_block(awaitable)
831
832
if cancelled and not cancellable:
832
833
assert (self .state == Task.State.INITIAL )
833
834
self .state = Task.State.PENDING_CANCEL
834
835
cancelled = await self .on_block(awaitable)
835
836
assert (not cancelled)
837
+
836
838
if sync:
837
839
self .inst.calling_sync_import = False
838
840
self .inst.async_waiting_tasks.notify_all()
839
841
else :
840
842
while self .inst.calling_sync_import:
841
843
await self .inst.async_waiting_tasks.wait()
844
+
842
845
return cancelled
843
846
```
844
847
If ` wait_on ` is called with ` sync ` set to ` True ` , only tasks in * other*
Original file line number Diff line number Diff line change @@ -531,24 +531,27 @@ def maybe_start_pending_task(self):
531
531
return
532
532
533
533
async def wait_on (self , awaitable , sync , cancellable = False ) -> bool :
534
- awaitable = asyncio .ensure_future (awaitable )
535
- assert (not self .inst .calling_sync_import )
536
534
if sync :
535
+ assert (not self .inst .calling_sync_import )
537
536
self .inst .calling_sync_import = True
538
537
else :
539
538
self .maybe_start_pending_task ()
539
+
540
+ awaitable = asyncio .ensure_future (awaitable )
540
541
cancelled = await self .on_block (awaitable )
541
542
if cancelled and not cancellable :
542
543
assert (self .state == Task .State .INITIAL )
543
544
self .state = Task .State .PENDING_CANCEL
544
545
cancelled = await self .on_block (awaitable )
545
546
assert (not cancelled )
547
+
546
548
if sync :
547
549
self .inst .calling_sync_import = False
548
550
self .inst .async_waiting_tasks .notify_all ()
549
551
else :
550
552
while self .inst .calling_sync_import :
551
553
await self .inst .async_waiting_tasks .wait ()
554
+
552
555
return cancelled
553
556
554
557
async def call_sync (self , callee , on_start , on_return ):
You can’t perform that action at this time.
0 commit comments