parent
3a8d4ec10b
commit
91fe21ab60
|
@ -42,6 +42,8 @@ try:
|
|||
except ImportError:
|
||||
import trollius as asyncio
|
||||
|
||||
IS_PYTHON_344_PLUS = platform.python_version_tuple() >= ('3', '4', '4')
|
||||
|
||||
|
||||
class DgramAsyncioProtocol(asyncio.DatagramProtocol, AbstractAsyncioTransport):
|
||||
"""Base Asyncio datagram Transport, to be used with AsyncioDispatcher"""
|
||||
|
@ -78,20 +80,18 @@ class DgramAsyncioProtocol(asyncio.DatagramProtocol, AbstractAsyncioTransport):
|
|||
debug.logger & debug.flagIO and debug.logger('connection_lost: invoked')
|
||||
|
||||
# AbstractAsyncioTransport API
|
||||
|
||||
python344 = platform.python_version_tuple() >= ('3', '4', '4')
|
||||
|
||||
|
||||
def openClientMode(self, iface=None):
|
||||
try:
|
||||
c = self.loop.create_datagram_endpoint(
|
||||
lambda: self, local_addr=iface, family=self.sockFamily
|
||||
)
|
||||
# Avoid deprecation warning for asyncio.async()
|
||||
if python344:
|
||||
if IS_PYTHON_344_PLUS:
|
||||
self._lport = asyncio.ensure_future(c)
|
||||
else: # pragma: no cover
|
||||
self._lport = asyncio.async(c)
|
||||
|
||||
|
||||
except Exception:
|
||||
raise error.CarrierError(';'.join(traceback.format_exception(*sys.exc_info())))
|
||||
return self
|
||||
|
|
|
@ -41,7 +41,7 @@ try:
|
|||
except ImportError:
|
||||
import trollius as asyncio
|
||||
|
||||
python344 = platform.python_version_tuple() >= ('3', '4', '4')
|
||||
IS_PYTHON_344_PLUS = platform.python_version_tuple() >= ('3', '4', '4')
|
||||
|
||||
class AsyncioDispatcher(AbstractTransportDispatcher):
|
||||
"""AsyncioDispatcher based on asyncio event loop"""
|
||||
|
@ -72,7 +72,7 @@ class AsyncioDispatcher(AbstractTransportDispatcher):
|
|||
def registerTransport(self, tDomain, transport):
|
||||
if self.loopingcall is None and self.getTimerResolution() > 0:
|
||||
# Avoid deprecation warning for asyncio.async()
|
||||
if python344:
|
||||
if IS_PYTHON_344_PLUS:
|
||||
self.loopingcall = asyncio.ensure_future(self.handle_timeout())
|
||||
else: # pragma: no cover
|
||||
self.loopingcall = asyncio.async(self.handle_timeout())
|
||||
|
|
Loading…
Reference in New Issue