@@ -183,29 +183,26 @@ def emit(self, data: Telemetry) -> None:
183183 if len (self ._queue ) >= self ._max_export_batch_size :
184184 self ._worker_awaken .set ()
185185
186- def shutdown (self , timeout_millis : int = 30000 ):
186+ def shutdown (self , timeout_secs : int = 30 ):
187187 if self ._shutdown :
188188 return
189- shutdown_should_end = time .time () + timeout_millis / 1000
189+ shutdown_should_end = time .time () + timeout_secs
190190 # Causes emit to reject telemetry and makes force_flush a no-op.
191191 self ._shutdown = True
192192 # Interrupts sleep in the worker if it's sleeping.
193193 self ._worker_awaken .set ()
194- self ._worker_thread .join (timeout_millis / 1000 )
194+ self ._worker_thread .join (timeout_secs )
195195 # Stops worker thread from calling export again if queue is still not empty.
196196 self ._shutdown_timeout_exceeded = True
197- # We want to shutdown immediately only if we already waited `timeout_millis `.
197+ # We want to shutdown immediately only if we already waited `timeout_secs `.
198198 # Otherwise we pass the remaining timeout to the exporter.
199199 # Some exporter's shutdown support a timeout param.
200200 if (
201201 "timeout_millis"
202202 in inspect .getfullargspec (self ._exporter .shutdown ).args
203203 ):
204- remaining_time = shutdown_should_end - time .time ()
205- if remaining_time < 0 :
206- self ._exporter .shutdown (timeout_millis = 0 ) # type: ignore
207- else :
208- self ._exporter .shutdown (timeout_millis = remaining_time * 1000 ) # type: ignore
204+ remaining_millis = (shutdown_should_end - time .time ()) * 1000
205+ self ._exporter .shutdown (timeout_millis = max (0 , remaining_millis )) # type: ignore
209206 else :
210207 self ._exporter .shutdown ()
211208 # Worker thread **should** be finished at this point, because we called shutdown on the exporter,
0 commit comments