Browse Source

network: (trivial) simplify send_http_on_proxy

master
SomberNight 2 years ago
parent
commit
bc57926498
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 8
      electrum/network.py

8
electrum/network.py

@ -1453,12 +1453,8 @@ class Network(Logger, NetworkRetryManager[ServerAddr]):
@classmethod @classmethod
def send_http_on_proxy(cls, method, url, **kwargs): def send_http_on_proxy(cls, method, url, **kwargs):
network = cls.get_instance() loop = util.get_asyncio_loop()
if network: assert util.get_running_loop() != loop, 'must not be called from asyncio thread'
assert util.get_running_loop() != network.asyncio_loop
loop = network.asyncio_loop
else:
loop = util.get_asyncio_loop()
coro = asyncio.run_coroutine_threadsafe(cls.async_send_http_on_proxy(method, url, **kwargs), loop) coro = asyncio.run_coroutine_threadsafe(cls.async_send_http_on_proxy(method, url, **kwargs), loop)
# note: _send_http_on_proxy has its own timeout, so no timeout here: # note: _send_http_on_proxy has its own timeout, so no timeout here:
return coro.result() return coro.result()

Loading…
Cancel
Save