File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -935,21 +935,24 @@ def close( # type: ignore[override]
935
935
Close the client and shut down the transport. Arguments have the same
936
936
semantics as :py:meth:`Client.flush`. When using the async transport, close needs to be awaited to block.
937
937
"""
938
+
939
+ async def _flush_and_close (
940
+ timeout : Optional [float ], callback : Optional [Callable [[int , float ], None ]]
941
+ ) -> None :
942
+ await self ._flush_async (timeout = timeout , callback = callback )
943
+ self ._close_components ()
944
+
938
945
if self .transport is not None :
939
946
if isinstance (self .transport , AsyncHttpTransport ):
940
947
941
- def _on_flush_done (_ : asyncio .Task [None ]) -> None :
942
- self ._close_components ()
943
-
944
948
try :
945
949
flush_task = self .transport .loop .create_task (
946
- self . _flush_async (timeout , callback )
950
+ _flush_and_close (timeout , callback )
947
951
)
948
952
except RuntimeError :
949
953
logger .warning ("Event loop not running, aborting close." )
950
954
return None
951
955
# Enforce flush before shutdown
952
- flush_task .add_done_callback (_on_flush_done )
953
956
return flush_task
954
957
else :
955
958
self .flush (timeout = timeout , callback = callback )
You can’t perform that action at this time.
0 commit comments