File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717
1818async def await_executor_future (future : asyncio .Future ):
19- """Await executor work without releasing a lock before cancellation
20- ends."""
21- cancelled = False
22- while not future .done ():
23- try :
24- result = await asyncio .shield (future )
25- except asyncio .CancelledError :
26- cancelled = True
27- except Exception :
28- if cancelled :
29- raise asyncio .CancelledError
30- raise
31- else :
32- if cancelled :
33- raise asyncio .CancelledError
34- return result
35-
36- if cancelled :
19+ """Await executor work without releasing a lock before it finishes."""
20+ try :
21+ return await asyncio .shield (future )
22+ except asyncio .CancelledError :
3723 try :
38- future . exception ()
24+ await future
3925 except BaseException :
4026 pass
41- raise asyncio .CancelledError
42- return future .result ()
27+ raise
4328
4429
4530class _ASNI_COLOR :
You can’t perform that action at this time.
0 commit comments