I find myself in the situation that I need to synchronize Trio tasks with Python threads. At the moment, I am using threading.Lock objects that Trio tasks have to acquire with trio.run_sync_in_worker_thread(lock.acquire). I think it should also be possible to use trio. Lock locks and have the threads acquire them with trio.BlockingTrioPortal.run_sync(lock.acquire). Does either of these solutions have advantages over the other? Would in in principle be possible to do better than this? E.g. to implement a "native" trio method that waits for a threading.Lock without the need for a separate worker thread, or are there fundamental reasons why this is required? Continue reading...