network: (trivial) simplify send_http_on_proxy
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user