remove get_running_loop patch

This commit is contained in:
Jack Robison 2018-10-19 10:27:38 -04:00
parent b07f529dcf
commit 6be98bec20
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
4 changed files with 5 additions and 23 deletions

View file

@ -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)

View file

@ -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(

View file

@ -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(

View file

@ -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,7 +382,6 @@ class UPnP:
wrapper = lambda : None
loop.run_until_complete(wrapper())
if close_loop:
loop.close()
try:
result = fut.result()