Skip to content

Commit f47c24d

Browse files
committed
Change variable names
1 parent adbe4b0 commit f47c24d

File tree

1 file changed

+6
-9
lines changed
  • opentelemetry-sdk/src/opentelemetry/sdk/_shared_internal

1 file changed

+6
-9
lines changed

opentelemetry-sdk/src/opentelemetry/sdk/_shared_internal/__init__.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)