@@ -199,6 +199,7 @@ def __init__(
199199 self ._schedule_delay = schedule_delay_millis / 1e3
200200 self ._max_export_batch_size = max_export_batch_size
201201 # Not used. No way currently to pass timeout to export.
202+ # TODO(https://github.com/open-telemetry/opentelemetry-python/issues/4555): figure out what this should do.
202203 self ._export_timeout_millis = export_timeout_millis
203204 # Deque is thread safe.
204205 self ._queue = collections .deque ([], max_queue_size )
@@ -210,7 +211,7 @@ def __init__(
210211
211212 self ._shutdown = False
212213 self ._export_lock = threading .Lock ()
213- self ._worker_sleep = threading .Event ()
214+ self ._worker_awaken = threading .Event ()
214215 self ._worker_thread .start ()
215216 if hasattr (os , "register_at_fork" ):
216217 os .register_at_fork (after_in_child = self ._at_fork_reinit ) # pylint: disable=protected-access
@@ -224,15 +225,15 @@ def _should_export_batch(
224225 # Always continue to export while queue length exceeds max batch size.
225226 if len (self ._queue ) >= self ._max_export_batch_size :
226227 return True
227- if batch_strategy == BatchLogExportStrategy .EXPORT_ALL :
228+ if batch_strategy is BatchLogExportStrategy .EXPORT_ALL :
228229 return True
229- if batch_strategy == BatchLogExportStrategy .EXPORT_AT_LEAST_ONE_BATCH :
230+ if batch_strategy is BatchLogExportStrategy .EXPORT_AT_LEAST_ONE_BATCH :
230231 return num_iterations == 0
231232 return False
232233
233234 def _at_fork_reinit (self ):
234235 self ._export_lock = threading .Lock ()
235- self ._worker_sleep = threading .Event ()
236+ self ._worker_awaken = threading .Event ()
236237 self ._queue .clear ()
237238 self ._worker_thread = threading .Thread (
238239 name = "OtelBatchLogRecordProcessor" ,
@@ -247,15 +248,15 @@ def worker(self):
247248 # Lots of strategies in the spec for setting next timeout.
248249 # https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#batching-processor.
249250 # Shutdown will interrupt this sleep. Emit will interrupt this sleep only if the queue is bigger then threshold.
250- sleep_interrupted = self ._worker_sleep .wait (self ._schedule_delay )
251+ sleep_interrupted = self ._worker_awaken .wait (self ._schedule_delay )
251252 if self ._shutdown :
252253 break
253254 self ._export (
254255 BatchLogExportStrategy .EXPORT_WHILE_BATCH_EXCEEDS_THRESHOLD
255256 if sleep_interrupted
256257 else BatchLogExportStrategy .EXPORT_AT_LEAST_ONE_BATCH
257258 )
258- self ._worker_sleep .clear ()
259+ self ._worker_awaken .clear ()
259260 self ._export (BatchLogExportStrategy .EXPORT_ALL )
260261
261262 def _export (self , batch_strategy : BatchLogExportStrategy ) -> None :
@@ -285,7 +286,7 @@ def _export(self, batch_strategy: BatchLogExportStrategy) -> None:
285286
286287 def emit (self , log_data : LogData ) -> None :
287288 if self ._shutdown :
288- _logger .warning ("Shutdown called, ignoring log." )
289+ _logger .info ("Shutdown called, ignoring log." )
289290 return
290291 if self ._pid != os .getpid ():
291292 _BSP_RESET_ONCE .do_once (self ._at_fork_reinit )
@@ -294,15 +295,15 @@ def emit(self, log_data: LogData) -> None:
294295 _logger .warning ("Queue full, dropping log." )
295296 self ._queue .appendleft (log_data )
296297 if len (self ._queue ) >= self ._max_export_batch_size :
297- self ._worker_sleep .set ()
298+ self ._worker_awaken .set ()
298299
299300 def shutdown (self ):
300301 if self ._shutdown :
301302 return
302303 # Prevents emit and force_flush from further calling export.
303304 self ._shutdown = True
304305 # Interrupts sleep in the worker, if it's sleeping.
305- self ._worker_sleep .set ()
306+ self ._worker_awaken .set ()
306307 # Main worker loop should exit after one final export call with flush all strategy.
307308 self ._worker_thread .join ()
308309 self ._exporter .shutdown ()
0 commit comments