Skip to content

Update dist.py#2985

Closed
doomedraven wants to merge 9 commits into
masterfrom
doomedraven-patch-5
Closed

Update dist.py#2985
doomedraven wants to merge 9 commits into
masterfrom
doomedraven-patch-5

Conversation

@doomedraven
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread utils/dist.py
Comment thread utils/dist.py
Comment thread utils/dist.py
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}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

There are two issues with this line:

  1. Accessing self.fetcher_queue.queue directly is not thread-safe. Iterating over the underlying deque while other threads are modifying the queue can lead to a RuntimeError.
  2. 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 a TypeError.

Comment thread utils/dist.py Outdated
Comment thread utils/dist.py
task = db.get(Task, task_id)
check = False

if node.name == main_server_name:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

If node is None (e.g., if the node_id provided does not exist in the database), this line will raise an AttributeError. A defensive check should be added after fetching the node and task objects at lines 379-380.

Comment thread utils/dist.py Outdated
Comment thread utils/dist.py
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Remove debug print statement.

Comment thread utils/dist.py
)
t = db.scalar(stmt)
if t is None:
print(type(self.t_is_none.get(node_id)))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Remove debug print statement.

Comment thread utils/dist.py Outdated
Comment thread utils/dist.py Outdated
doomedraven and others added 8 commits April 17, 2026 17:16
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.
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.

1 participant