I’m a bit confused with what parts of bokeh are async and what aren’t - in my bokeh server application, if I need to run something that can only run in a synchronous environment then I need to do:
def app(doc): ... def sync_only(): ... executor = concurrent.futures.ThreadPoolExecutor() future = executor.submit(sync_only) result = future.result() executor.shutdown()
Which is surprising in of itself since it’s not declared as async def
Then in another instance I wanted to run an async function in
app so I figured I had to do -
asgiref.async_to_sync(async_function)(arg), but that doesn’t work either (error -
You cannot use AsyncToSync in the same thread as an async event loop - just await the async function directly)… Ok so then if I just await it it of course complains that the function needs to be declared
async, so I declare it async and now it’s not even getting run at all (I’m assuming this is due to it not being awaited higher up)… so I’m at a bit of a loss given it seems to be in between async and sync.