Avoid deprecation warnings for asyncio.async() in server mode (#202)
This is actually needed for Python 3.7 which introduces async and await as reserved keywords, see https://docs.python.org/3/whatsnew/3.7.htmlasync-mib-instrumentation
parent
53e67f9533
commit
35e9c6f7a6
|
@ -101,7 +101,11 @@ class DgramAsyncioProtocol(asyncio.DatagramProtocol, AbstractAsyncioTransport):
|
|||
c = self.loop.create_datagram_endpoint(
|
||||
lambda: self, local_addr=iface, family=self.sockFamily
|
||||
)
|
||||
self._lport = getattr(asyncio, 'async')(c)
|
||||
# Avoid deprecation warning for asyncio.async()
|
||||
if IS_PYTHON_344_PLUS:
|
||||
self._lport = asyncio.ensure_future(c)
|
||||
else: # pragma: no cover
|
||||
self._lport = getattr(asyncio, 'async')(c)
|
||||
except Exception:
|
||||
raise error.CarrierError(';'.join(traceback.format_exception(*sys.exc_info())))
|
||||
return self
|
||||
|
|
Loading…
Reference in New Issue