summaryrefslogtreecommitdiff
path: root/pysnmp
diff options
context:
space:
mode:
authorFabrizio Vanni <fabriziovanni@users.noreply.github.com>2018-09-26 11:12:30 +0200
committerIlya Etingof <etingof@gmail.com>2018-09-26 11:12:30 +0200
commit35e9c6f7a6620eb2b2dc6941cd0d2e1bf3816e04 (patch)
tree3fb512ae716e87ac0880ca023519c5edf7f9ee19 /pysnmp
parent53e67f9533c98eb9a626ce20c31e21250a55bd63 (diff)
downloadpysnmp-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
Diffstat (limited to 'pysnmp')
-rw-r--r--pysnmp/carrier/asyncio/dgram/base.py6
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