Skip to content

fix: threadsafe lob_print#15

Merged
MrKevinWeiss merged 6 commits intomasterfrom
pr/threadsafeprint
Apr 9, 2026
Merged

fix: threadsafe lob_print#15
MrKevinWeiss merged 6 commits intomasterfrom
pr/threadsafeprint

Conversation

@MrKevinWeiss
Copy link
Copy Markdown
Collaborator

This pull request improves thread safety and reliability in the logging setup of the lob_print function by introducing a lock to prevent race conditions when multiple threads attempt to configure file handlers simultaneously. Additionally, it clarifies the logic for attaching handlers to loggers. The most important changes are:

Thread safety improvements:

  • Added a threading.Lock (_log_handler_lock) to protect the one-time setup of rotating file handlers in lob_print, ensuring that concurrent threads do not create duplicate handlers or encounter race conditions. [1] [2] [3]

Logging handler setup adjustments:

  • Modified the logic for adding file handlers so that handlers are added to both the root logger (for propagation) and the specific logger (since propagate=False), ensuring correct logging behavior.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves reliability of LobHlpr.lob_print() logging by making rotating file handler setup thread-safe and clarifying how handlers are attached to ensure logs are written even with propagate=False.

Changes:

  • Added a module-level lock to prevent concurrent threads from creating duplicate RotatingFileHandlers.
  • Switched handler detection to use an absolute log path and re-check under the lock.
  • Adjusted handler attachment to include both the root logger and the lob_hlpr logger.

@MrKevinWeiss
Copy link
Copy Markdown
Collaborator Author

A few extra things that are nice, but not really that needed...

@MrKevinWeiss MrKevinWeiss merged commit a0fa9be into master Apr 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants