-
Notifications
You must be signed in to change notification settings - Fork 57
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
Question: Periodic BrokenBarrierError #35
Comments
I think the issue is that the Executor is timing out waiting on javascript. Is there a way to increase the timeout, or better yet let it sit forever? |
Hello Can you provide a stack trace (or reproducible code sample) for when you get the error? It's possible there's a race condition somewhere. To make things simple internally we automatically await everything turned over from JS to Python. As for the timeout issue: if you do a function call with the keyword argument fn(timeout=None)
# with normal args + no timeout:
fn('normal', 'arguments', timeout=None) |
I think, honestly, a simpler explanation is that the API I'm calling into is not responding due to load. I will try and do some more digging, and get back to you soon. |
I encountered a very similar issue where BrokenBarrierError occurred during a long-running process that repeatedly invoked a JavaScript async function in Python's future objects created by ThreadPoolExecutor with max_workers=16. I suspect that the timeout for the Barrier is too short for our use case. JSPyBridge/src/javascript/events.py Lines 179 to 180 in bd17b0d
To address this, I am considering the following adjustments: lock, timeout = self.requests[r]
barrier = threading.Barrier(2, timeout=timeout) Would this approach resolve this issue without compromising the overall architecture? |
Sure, you can make a PR if you can confirm it fixes your use case |
Thank @extremeheat for your encouragement: #35 (comment). At the moment, I cannot confirm whether my hypothesis is correct. If necessary, I will submit a PR. Thank you for the excellent work on this project. |
I have an application where I periodically call an async function that lives in JS land,
poll()
.It calls it from the main runtime of Python, not an async context.
This makes various API calls and returns a promise for the results of those calls.
It works for the most part, but occasionally I need to restart the application because the call to
poll
results in BrokenBarrierError.I read through a bit of stdlib.d.ts, and it looks like the cases where this can happen is when something calls
reset()
or when something callsabort()
. Is there a smarter way that I should be handling this?Should I make sure that all promises on the JS side have returned before trying to inspect them in Python?
Should I have something running in the async Python context to interact with async javascript objects?
How do I minimize my exposure to this issue?
Any guidance you can provide is appreciated!
The text was updated successfully, but these errors were encountered: