audiokinetic / waapi-client-python

Decoupled autobahn WAMP client with support for plain options and bindable subscription callbacks
Apache License 2.0
41 stars 6 forks source link

fixed: exception about missing event loop in thread-pool when other processes create their own event loops #10

Open kakyoism opened 3 years ago

kakyoism commented 3 years ago

With current waapi-client, we get an error looking like this

 RuntimeError: There is no current event loop in thread 'ThreadPoolExecutor-0_0'.

when the caller process already uses an asyncio event loop.

So to solve this problem, I had to use this patch locally. Hope this patch helps with a sound solution to this scenario, which could happen often if external IPC is involved on the WAAPI caller side.

kakyoism commented 3 years ago

I'm not entirely sure about commit 0b0ef8c8668e1d54ca27582d2827efdf7e5ca76a, but I think the event loop will not close itself on bailouts due to runtime errors, so I took some cautions there. Feel free to correct me if I'm wrong, please.

ak-slongchamps commented 3 years ago

Moving to draft: larger work needed for graceful termination when multiple async loops are involved.