asyncio.wait_for() is too buggy. use util.wait_for2() instead
wasted some time because asyncio.wait_for() was suppressing cancellations. [0][1][2] deja vu... [3] Looks like this is finally getting fixed in cpython 3.12 [4] So far away... In attempt to avoid encountering this again, let's try using asyncio.timeout in 3.11, which is how upstream reimplemented wait_for in 3.12 [4], and aiorpcx.timeout_after in 3.8-3.10. [0] https://github.com/python/cpython/issues/86296 [1] https://bugs.python.org/issue42130 [2] https://bugs.python.org/issue45098 [3] https://github.com/kyuupichan/aiorpcX/issues/44 [4] https://github.com/python/cpython/pull/98518
This commit is contained in:
@@ -11,7 +11,7 @@ import time
|
||||
|
||||
from electrum.logging import get_logger, configure_logging
|
||||
from electrum.simple_config import SimpleConfig
|
||||
from electrum import constants
|
||||
from electrum import constants, util
|
||||
from electrum.daemon import Daemon
|
||||
from electrum.wallet import create_new_wallet
|
||||
from electrum.util import create_and_start_event_loop, log_exceptions, bfh
|
||||
@@ -84,7 +84,7 @@ async def worker(work_queue: asyncio.Queue, results_queue: asyncio.Queue, flag):
|
||||
print(f"worker connecting to {connect_str}")
|
||||
try:
|
||||
peer = await wallet.lnworker.add_peer(connect_str)
|
||||
res = await asyncio.wait_for(peer.initialized, TIMEOUT)
|
||||
res = await util.wait_for2(peer.initialized, TIMEOUT)
|
||||
if res:
|
||||
if peer.features & flag == work['features'] & flag:
|
||||
await results_queue.put(True)
|
||||
|
||||
Reference in New Issue
Block a user