Open
Conversation
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 |
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. Additionally, `_sync` functions now auto-start the singleton server instead of falling back to `oneshot_async_run`, which creates a new thread and event loop per call and can also hang under load. The `atexit` handler that called `close()` → `thread.join()` is removed since the server thread is already `daemon=True` and will exit with the process. The `join()` could hang if Chromium shutdown blocks. Reproduces ~1/1000 calls with 64 threads. See plotly/plotly.py#5549
d6058a1 to
f5426b1
Compare
Author
|
Hi @emilykl ! I've force-pushed the branch - it's now rebased on master with workflows restored and all changes in a single clean commit. With the fix applied, we ran 6000+ calls with zero hangs. |
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