dieter.mau...@online.de wrote at 2024-3-22 18:28 +0100: >Thomas Nyberg wrote at 2024-3-22 11:08 +0100: >> ... `future` use across thread boundaries ... >> Here's an example using just the standard library that >> exhibits the same issue: > ... >For use across thread boundaries, you likely will use >`concurrent.Future` (not `asyncio.Future`). >You can use `asyncio.futures._chain_futures` to associate >an `asyncio.Future` with a `concurrent.Future`. >Then the fate (result or exception set) of one will be reflected in the other.
You must not set the result/exception for a future in a "foreign" thread ("foreign" here means one not associated with the future's loop). An aternative to the solution sketched above is to set the result indirectly via `loop.call_soon_threadsafe`. This way, the result is set in the futures "native" thread. -- https://mail.python.org/mailman/listinfo/python-list