asyncio icon indicating copy to clipboard operation
asyncio copied to clipboard

Python: run_soon_threadsafe

Open 0lru opened this issue 1 year ago • 0 comments

Nice Python-like-API-approach. I started something like this some time ago and my event loop class looked pretty much the same.

In Python, you can have multiple event loops: See https://docs.python.org/3/library/asyncio-eventloop.html call_soon_threadsafe, set_event_loop etc.

I think it's about making this a thread_local:

EventLoop& get_event_loop() {
    static EventLoop loop;
    return loop;
}

The continuation may be a bit different as well. I'd love a combination of this API with the multithreading-capabilities of https://github.com/David-Haim/concurrencpp.

0lru avatar Apr 08 '23 15:04 0lru