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:12:30 +0200 |
commit | 35e9c6f7a6620eb2b2dc6941cd0d2e1bf3816e04 (patch) | |
tree | 3fb512ae716e87ac0880ca023519c5edf7f9ee19 | |
parent | 53e67f9533c98eb9a626ce20c31e21250a55bd63 (diff) | |
download | pysnmp-git-35e9c6f7a6620eb2b2dc6941cd0d2e1bf3816e04.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 |