fix: improve thread safety and execution logging with minimal changes#184
Merged
prodigysml merged 1 commit intocodingo:masterfrom Apr 19, 2025
Merged
fix: improve thread safety and execution logging with minimal changes#184prodigysml merged 1 commit intocodingo:masterfrom
prodigysml merged 1 commit intocodingo:masterfrom
Conversation
- Replaces generator-based task queue with thread-safe queue.Queue in threader.py to prevent thread starvation - Moves '[THREAD] Added to Queue' logging from task generation to execution time - Integrates OutputHelper into Worker for consistent styled logs - Preserves original behavior of stderr visibility and test harness - Updates interlace.py to pass output_helper, removes duplicate logging - Retains original structure, repeat logic, and test interface to minimize diff
There was a problem hiding this comment.
Pull Request Overview
This PR enhances thread safety and logging clarity by replacing the iterator‐based task queue with a thread-safe queue and by moving the "[THREAD] Added to Queue" message to the actual task execution phase. Key changes include the introduction of queue.Queue in the Pool, the addition of an OutputHelper for consistent styled terminal output, and a revised logging approach in Interlace to preserve output behavior.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Interlace/lib/threader.py | Switched to queue.Queue for task management and moved logging inside worker execution. |
| Interlace/interlace.py | Adjusted logging by commenting out early log output and passing output as output_helper. |
Comments suppressed due to low confidence (2)
Interlace/lib/threader.py:110
- [nitpick] The variable 'tasks_count' is derived from the first element of the task_queue iterator; consider renaming it to 'total_tasks' or adding a clarifying comment to indicate that the iterator's first value represents the total number of tasks.
tasks_count = next(task_queue)
Interlace/interlace.py:41
- Ensure that the 'output' passed as output_helper is an instance of OutputHelper, as expected by the Pool implementation, to maintain consistent logging behavior.
output_helper=output
prodigysml
approved these changes
Apr 19, 2025
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.
✨ Pull Request: Improve Thread Execution and Logging Behavior
Summary
This PR improves thread safety, execution accuracy, and log clarity in Interlace, while preserving the original behavior, structure, and test harness with minimal changes.
✅ What's Changed
threader.pynext(task_queue)with a thread-safequeue.Queueto prevent premature thread exits.[THREAD] Added to Queuelogging from task generation time to actual execution time (inside each worker thread).OutputHelperto enable consistent, styled terminal output from within threads.interlace.pyoutput_helper=outputtoPoolfor use inside threads.[THREAD] ... Added to Queuelog from task queue generator.✅ Why It Matters