File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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
821821Python [ awaitable] using the ` OnBlock ` callback described above:
822822``` python
823823 async def wait_on (self , awaitable , sync , cancellable = False ) -> bool :
824- awaitable = asyncio.ensure_future(awaitable)
825- assert (not self .inst.calling_sync_import)
826824 if sync:
825+ assert (not self .inst.calling_sync_import)
827826 self .inst.calling_sync_import = True
828827 else :
829828 self .maybe_start_pending_task()
829+
830+ awaitable = asyncio.ensure_future(awaitable)
830831 cancelled = await self .on_block(awaitable)
831832 if cancelled and not cancellable:
832833 assert (self .state == Task.State.INITIAL )
833834 self .state = Task.State.PENDING_CANCEL
834835 cancelled = await self .on_block(awaitable)
835836 assert (not cancelled)
837+
836838 if sync:
837839 self .inst.calling_sync_import = False
838840 self .inst.async_waiting_tasks.notify_all()
839841 else :
840842 while self .inst.calling_sync_import:
841843 await self .inst.async_waiting_tasks.wait()
844+
842845 return cancelled
843846```
844847If ` 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):
531531 return
532532
533533 async def wait_on (self , awaitable , sync , cancellable = False ) -> bool :
534- awaitable = asyncio .ensure_future (awaitable )
535- assert (not self .inst .calling_sync_import )
536534 if sync :
535+ assert (not self .inst .calling_sync_import )
537536 self .inst .calling_sync_import = True
538537 else :
539538 self .maybe_start_pending_task ()
539+
540+ awaitable = asyncio .ensure_future (awaitable )
540541 cancelled = await self .on_block (awaitable )
541542 if cancelled and not cancellable :
542543 assert (self .state == Task .State .INITIAL )
543544 self .state = Task .State .PENDING_CANCEL
544545 cancelled = await self .on_block (awaitable )
545546 assert (not cancelled )
547+
546548 if sync :
547549 self .inst .calling_sync_import = False
548550 self .inst .async_waiting_tasks .notify_all ()
549551 else :
550552 while self .inst .calling_sync_import :
551553 await self .inst .async_waiting_tasks .wait ()
554+
552555 return cancelled
553556
554557 async def call_sync (self , callee , on_start , on_return ):
You can’t perform that action at this time.
0 commit comments