T-17170 Flush after each RQ job and start forked children with a clean handler - #47
Merged
Merged
Conversation
… forked children inheriting the parent's handler state RQ ends every work horse with os._exit(), so nothing flushes the handler; a logtail.rq.Worker that flushes after each job is expected. A forked child also inherits the parent's queue, flush thread object and HTTP session. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…TP session Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…very RQ job Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
PetrHeinz
marked this pull request as ready for review
September 24, 2026 14:13
…ork-flush # Conflicts: # tests/test_handler.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RQ runs every job in a forked work horse that ends with
os._exit(), which skips the interpreter shutdown that normally lets the handler send what it has buffered. A job that finishes within the flush interval therefore loses all of its records. That is the pattern in #36: the long-lived worker's ownrq.workerlines arrive, the job's own lines do not.Two changes, tests first (the first commit is expected to fail CI):
logtail.rq.Workerflushes everyLogtailHandlerafter each job, inside the work horse, before RQ exits it. Use it withrq worker --worker-class logtail.rq.Worker, orRQ = {"WORKER_CLASS": "logtail.rq.Worker"}with django-rq.rqstays out of the package's dependencies, the module only imports it when used.requests.Sessionwhose socket it shared with the parent.🤖 Generated with Claude Code