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]
935935 Close the client and shut down the transport. Arguments have the same
936936 semantics as :py:meth:`Client.flush`. When using the async transport, close needs to be awaited to block.
937937 """
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+
938945 if self .transport is not None :
939946 if isinstance (self .transport , AsyncHttpTransport ):
940947
941- def _on_flush_done (_ : asyncio .Task [None ]) -> None :
942- self ._close_components ()
943-
944948 try :
945949 flush_task = self .transport .loop .create_task (
946- self . _flush_async (timeout , callback )
950+ _flush_and_close (timeout , callback )
947951 )
948952 except RuntimeError :
949953 logger .warning ("Event loop not running, aborting close." )
950954 return None
951955 # Enforce flush before shutdown
952- flush_task .add_done_callback (_on_flush_done )
953956 return flush_task
954957 else :
955958 self .flush (timeout = timeout , callback = callback )
You can’t perform that action at this time.
0 commit comments