File tree Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -56,21 +56,24 @@ def get_timeout(self, timeout_flag: asyncio.Event) -> Optional[ItemType]:
56
56
asyncio .ensure_future (self .async_get (), loop = self .loop ),
57
57
asyncio .ensure_future (asyncio .wait_for (timeout_flag .wait (), timeout = 10 ), loop = self .loop ),
58
58
]
59
- done , pending = asyncio .run_coroutine_threadsafe (
60
- asyncio .wait (
61
- tasks ,
62
- return_when = asyncio .FIRST_COMPLETED ,
63
- ),
64
- self .loop ,
65
- ).result ()
66
- for task in pending :
67
- task .cancel ()
68
- result = list (done )[0 ].result ()
69
- timeout_flag .clear ()
70
- if result is True :
59
+ try :
60
+ done , pending = asyncio .run_coroutine_threadsafe (
61
+ asyncio .wait (
62
+ tasks ,
63
+ return_when = asyncio .FIRST_COMPLETED ,
64
+ ),
65
+ self .loop ,
66
+ ).result ()
67
+ for task in pending :
68
+ task .cancel ()
69
+ result = list (done )[0 ].result ()
70
+ timeout_flag .clear ()
71
+ if result is True :
72
+ return None
73
+ else :
74
+ return result
75
+ except asyncio .exceptions .TimeoutError :
71
76
return None
72
- else :
73
- return result
74
77
75
78
async def async_put (self , item : ItemType ):
76
79
await self .queue .put (item )
You can’t perform that action at this time.
0 commit comments