You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In contrast to most JavaScript code, Python libraries often work synchronously and may even expect one's callback function to resolve synchronously, even if that doesn't make sense in JavaScript environment. One example might be the audible Python package that performs all HTTP requests synchronously and expects a synchronous callback to show an image to the user and get their response.
I have no experience with Deno's FFI yet, but it seems to me that calling synchronous Python functions asynchronously should be possible, as the Python interpreter runs in a different thread. Similarly, I would expect "converting" asynchronous JS functions to synchronous Python callbacks should be possible, if one blocks the Python interpreter until the JS promise is settled.
Is this something that sounds viable to you? And if so, is this something you'd be interested in adding to this library?
The text was updated successfully, but these errors were encountered:
cshaa
changed the title
Asynchronous callback?
Synchronous Python & async JavaScript?
May 26, 2023
While it should be possible to call sync Python functions asynchronously, the latter doesn't seem to work out. I tried it out and there is a deadlock. JS event loop does not step in an FFI callback's context which is further being waited upon by Python.
In contrast to most JavaScript code, Python libraries often work synchronously and may even expect one's callback function to resolve synchronously, even if that doesn't make sense in JavaScript environment. One example might be the
audible
Python package that performs all HTTP requests synchronously and expects a synchronous callback to show an image to the user and get their response.I have no experience with Deno's FFI yet, but it seems to me that calling synchronous Python functions asynchronously should be possible, as the Python interpreter runs in a different thread. Similarly, I would expect "converting" asynchronous JS functions to synchronous Python callbacks should be possible, if one blocks the Python interpreter until the JS promise is settled.
Is this something that sounds viable to you? And if so, is this something you'd be interested in adding to this library?
The text was updated successfully, but these errors were encountered: