I am trying to use asyncio and should mix it with some standard multi-threaded block code, so I need to offload the execution using run_in_exector.
asyncio docs warn that โmost functionsโ are not thread safe , and that call_soon_threadsafe
is the only thread protected function. There are a couple others, such as Future.add_done_callback
, which are explicitly documented as thread safe. He then has a sentence that says: "you can use run_in_executor to make callbacks in other threads," but do not comment on its safety.
run_in_executor is not doc'd for thread safety, but looking at the source, it looks like it is thread safe if the correct code paths are accepted.
Does anyone know if it should be thread safe, but just not documented that way?
source share