JSPyBridge
JSPyBridge copied to clipboard
Question: Periodic BrokenBarrierError
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 calls abort()
. 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!
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 timeout=None
at the end, no timeout check is done.
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.