remove get_running_loop patch
This commit is contained in:
parent
b07f529dcf
commit
6be98bec20
4 changed files with 5 additions and 23 deletions
|
@ -4,9 +4,3 @@ __author__ = "Jack Robison"
|
|||
__maintainer__ = "Jack Robison"
|
||||
__license__ = "MIT"
|
||||
__email__ = "jackrobison@lbry.io"
|
||||
|
||||
import sys
|
||||
import asyncio
|
||||
|
||||
if not hasattr(asyncio, "get_running_loop") and hasattr(asyncio, "_get_running_loop"): # python 3.6
|
||||
setattr(sys.modules['asyncio'], "get_running_loop", asyncio._get_running_loop)
|
||||
|
|
|
@ -92,7 +92,7 @@ class SCPDHTTPClientProtocol(Protocol):
|
|||
|
||||
async def scpd_get(control_url: str, address: str, port: int) -> typing.Tuple[typing.Dict, bytes,
|
||||
typing.Optional[Exception]]:
|
||||
loop = asyncio.get_running_loop()
|
||||
loop = asyncio.get_event_loop_policy().get_event_loop()
|
||||
finished: asyncio.Future = asyncio.Future()
|
||||
packet = serialize_scpd_get(control_url, address)
|
||||
transport, protocol = await loop.create_connection(
|
||||
|
@ -118,7 +118,7 @@ async def scpd_get(control_url: str, address: str, port: int) -> typing.Tuple[ty
|
|||
async def scpd_post(control_url: str, address: str, port: int, method: str, param_names: list, service_id: bytes,
|
||||
soap_socket: socket.socket = None, **kwargs) -> typing.Tuple[typing.Dict, bytes,
|
||||
typing.Optional[Exception]]:
|
||||
loop = asyncio.get_running_loop()
|
||||
loop = asyncio.get_event_loop_policy().get_event_loop()
|
||||
finished: asyncio.Future = asyncio.Future()
|
||||
packet = serialize_soap_post(method, param_names, service_id, address.encode(), control_url.encode(), **kwargs)
|
||||
transport, protocol = await loop.create_connection(
|
||||
|
|
|
@ -111,7 +111,7 @@ class SSDPProtocol(MulticastProtocol):
|
|||
async def listen_ssdp(lan_address: str, gateway_address: str, ssdp_socket: socket.socket = None,
|
||||
ignored: typing.Set[str] = None, unicast: bool = False) -> typing.Tuple[DatagramTransport,
|
||||
SSDPProtocol, str, str]:
|
||||
loop = asyncio.get_running_loop()
|
||||
loop = asyncio.get_event_loop_policy().get_event_loop()
|
||||
try:
|
||||
sock = ssdp_socket or SSDPProtocol.create_multicast_socket(lan_address)
|
||||
listen_result: typing.Tuple = await loop.create_datagram_endpoint(
|
||||
|
|
|
@ -346,18 +346,7 @@ class UPnP:
|
|||
kwargs = kwargs or {}
|
||||
igd_args = igd_args
|
||||
timeout = int(timeout)
|
||||
close_loop = False
|
||||
try:
|
||||
loop = asyncio.get_running_loop()
|
||||
except RuntimeError:
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
close_loop = True
|
||||
if not loop and not close_loop:
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
close_loop = True
|
||||
|
||||
loop = asyncio.get_event_loop_policy().get_event_loop()
|
||||
fut: asyncio.Future = asyncio.Future()
|
||||
|
||||
async def wrapper():
|
||||
|
@ -393,8 +382,7 @@ class UPnP:
|
|||
wrapper = lambda : None
|
||||
|
||||
loop.run_until_complete(wrapper())
|
||||
if close_loop:
|
||||
loop.close()
|
||||
loop.close()
|
||||
try:
|
||||
result = fut.result()
|
||||
except UPnPError as err:
|
||||
|
|
Loading…
Reference in a new issue