Open
Conversation
…access The shared _return_queue causes a race condition when multiple threads call to_image concurrently: task_queue.join() unblocks all waiters when the count hits zero, not when a specific task completes. Two threads race to return_queue.get(), one wins, the other blocks forever. Fix: give each caller its own Queue embedded in the Task. The server routes the result directly into it. No sharing, no race, no deadlock. Reproduces ~1/1000 calls with 64 threads. See plotly/plotly.py#5549 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
oneshot_async_run creates a new thread + event loop per call, which can also hang under load. Instead, auto-start the singleton server on first sync call so all requests go through the thread-safe per-caller queue. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The server thread is daemon=True so it dies with the process. The atexit close() calls thread.join() which hangs if Chromium shutdown blocks.
Collaborator
|
Hi @AndrushaUt, thanks for the PR. Were you able to come up with a way to reliably reproduce plotly/plotly.py#5549 ? That would be helpful in reviewing this fix. Could you also restore the deleted |
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.
…access
The shared _return_queue causes a race condition when multiple threads call to_image concurrently: task_queue.join() unblocks all waiters when the count hits zero, not when a specific task completes. Two threads race to return_queue.get(), one wins, the other blocks forever.
Fix: give each caller its own Queue embedded in the Task. The server routes the result directly into it. No sharing, no race, no deadlock.
Reproduces ~1/1000 calls with 64 threads.
See plotly/plotly.py#5549