-
Notifications
You must be signed in to change notification settings - Fork 8
Lets "task create" nodes run in parallel. #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR converts the WaveSpeed task submission and status checking nodes to use async/await patterns, enabling parallel execution of multiple task nodes similar to the approach described in the ComfyUI blog post about unlimited parallel API nodes.
Key Changes:
- Converted
submit_taskandcheck_statusmethods to async functions - Implemented
asyncio.run_in_executor()to run blocking API calls in thread pools without blocking the event loop
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| model_uuid = task_info.get("modelUUID") | ||
| if not model_uuid: | ||
| if not model_uuid: |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace at the end of the line. This should be removed to maintain code cleanliness and avoid unnecessary diff noise in version control.
| ) | ||
|
|
||
| if not response: | ||
| if not response: |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace at the end of the line. This should be removed to maintain code cleanliness and avoid unnecessary diff noise in version control.
| wait_for_completion: Whether to wait for completion | ||
| Returns: | ||
| Returns: |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace at the end of the line. This should be removed to maintain code cleanliness and avoid unnecessary diff noise in version control.
|
|
||
| # Use asyncio to run the blocking operation in a thread pool | ||
| loop = asyncio.get_event_loop() | ||
|
|
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace at the end of the line. This should be removed to maintain code cleanliness and avoid unnecessary diff noise in version control.
| timeout=max_wait_time | ||
| # Use asyncio to run the blocking operation in a thread pool | ||
| # This allows multiple tasks to run concurrently | ||
| loop = asyncio.get_event_loop() |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using asyncio.get_event_loop() is deprecated in Python 3.10+ and can cause issues. In async functions, you should use asyncio.get_running_loop() instead, which returns the currently running event loop. The get_event_loop() method may return a different loop or fail if no loop is running.
| print(f"Checking status for task {task_id}") | ||
|
|
||
| # Use asyncio to run the blocking operation in a thread pool | ||
| loop = asyncio.get_event_loop() |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using asyncio.get_event_loop() is deprecated in Python 3.10+ and can cause issues. In async functions, you should use asyncio.get_running_loop() instead, which returns the currently running event loop. The get_event_loop() method may return a different loop or fail if no loop is running.
| error_message = str(e) | ||
| print(f"Error in WaveSpeedTaskSubmit: {error_message}") | ||
| raise Exception(f"WaveSpeedTaskSubmit failed: {error_message}") | ||
| raise Exception(f"WaveSpeedTaskSubmit failed: {error_message}") |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space after colon in the error message. The line has two spaces after "failed:" instead of one, making it inconsistent with standard error message formatting.
| client: WaveSpeed API client | ||
| task_info: Task information from WaveSpeedTaskCreateDynamic | ||
| wait_for_completion: Whether to wait for completion | ||
| wait_for_completion: Whether to wait for completion |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space after colon in the parameter description. The line has two spaces after "completion:" instead of one, making it inconsistent with other parameter descriptions.
| else: | ||
| # Unknown status, throw error | ||
| raise Exception(f"Unknown task status: {status}") | ||
| raise Exception(f"Unknown task status: {status}") |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space after colon in the error message. The line has two spaces after "status:" instead of one, making it inconsistent with standard error message formatting.
Like https://blog.comfy.org/p/unlimited-parallel-api-nodes-and