Update dist.py#2985
Closed
doomedraven wants to merge 9 commits into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors utils/dist.py to introduce parallel task submission using ThreadPoolExecutor, improve database session management with context managers, and optimize URL construction using urljoin. Feedback identifies several critical issues, including a potential NameError from the removal of node_get_report, thread-safety concerns in queue handling, and possible AttributeError exceptions in error handling paths. Recommendations were also provided to improve portability using timestamp(), ensure proper session cleanup, and remove debug code.
| continue | ||
| processed_task_ids = set(self.current_queue.get(node.id, [])) | ||
| try: | ||
| queue_task_ids = {t[0] for t in self.fetcher_queue.queue if t[1] == node.id} |
Contributor
There was a problem hiding this comment.
There are two issues with this line:
- Accessing
self.fetcher_queue.queuedirectly is not thread-safe. Iterating over the underlying deque while other threads are modifying the queue can lead to aRuntimeError. - The items in the queue are tuples where the first element is a dictionary (e.g.,
{'id': task_id}). Dictionaries are unhashable, so attempting to create a set from them will raise aTypeError.
| task = db.get(Task, task_id) | ||
| check = False | ||
|
|
||
| if node.name == main_server_name: |
Contributor
| try: | ||
| queue_task_ids = {t[0] for t in self.fetcher_queue.queue if t[1] == node.id} | ||
| except TypeError: | ||
| print("queue_task_ids", self.fetcher_queue.queue) |
Contributor
| ) | ||
| t = db.scalar(stmt) | ||
| if t is None: | ||
| print(type(self.t_is_none.get(node_id))) |
Contributor
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Adds a new function to fetch reports for tasks from a specified URL.
Refactor logging to use a variable for debug messages and remove the fetch_latest_reports method.
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.
No description provided.