diff options
author | Fabrizio Vanni <fabriziovanni@users.noreply.github.com> | 2018-09-26 11:12:30 +0200 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2018-09-26 11:13:10 +0200 |
commit | c7f8654c98688b7967ce0dde9fa89b67ebe4b3d7 (patch) | |
tree | 8183ff997b435edb1069e652691fef1fe6753ebb | |
parent | 250deca6ed1866699ae980238592c00a423e5a67 (diff) | |
download | pysnmp-git-c7f8654c98688b7967ce0dde9fa89b67ebe4b3d7.tar.gz |
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.html
-rw-r--r-- | pysnmp/carrier/asyncio/dgram/base.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pysnmp/carrier/asyncio/dgram/base.py b/pysnmp/carrier/asyncio/dgram/base.py index 93e58457..af649db6 100644 --- a/pysnmp/carrier/asyncio/dgram/base.py +++ b/pysnmp/carrier/asyncio/dgram/base.py @@ -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 |