diff options
author | Chris Gunn <chrisgun@microsoft.com> | 2022-05-16 17:34:59 +0100 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2022-06-08 16:43:52 +0100 |
commit | ca3731a126da2ed7f2c235f84daf54638e8933a5 (patch) | |
tree | eb4d77f5c03898b961596d7f1ea8bbcb21504ebe /libvirtaio.py | |
parent | 8a0e3f052bbda52c15bef8ee50c8061b897a133c (diff) | |
download | libvirt-python-ca3731a126da2ed7f2c235f84daf54638e8933a5.tar.gz |
libvirtaio: drop back compat for python < 3.4.4
setup.py ensures we have python >= 3.5, so there is no need to do
back compat with the 'asyncio.ensure_future' method, which was new
in 3.4.4
Signed-off-by: Chris Gunn <chrisgun@microsoft.com>
[DB: Split off from a larger patch mixing multiple changes]
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'libvirtaio.py')
-rw-r--r-- | libvirtaio.py | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/libvirtaio.py b/libvirtaio.py index a2abf0c..a24d9d4 100644 --- a/libvirtaio.py +++ b/libvirtaio.py @@ -46,14 +46,6 @@ __all__ = [ 'virEventRegisterAsyncIOImpl', ] -# Python < 3.4.4 doesn't have 'ensure_future', so we have to fall -# back to 'async'; however, since 'async' is a reserved keyword -# in Python >= 3.7, we can't perform a straightforward import and -# we have to resort to getattr() instead -ensure_future = getattr(asyncio, "ensure_future", None) -if not ensure_future: - ensure_future = getattr(asyncio, "async") - class Callback(object): '''Base class for holding callback @@ -248,8 +240,8 @@ class TimeoutCallback(Callback): if self.timeout >= 0 and self._task is None: self.impl.log.debug('timer %r start', self.iden) - self._task = ensure_future(self._timer(), - loop=self.impl.loop) + self._task = asyncio.ensure_future(self._timer(), + loop=self.impl.loop) elif self.timeout < 0 and self._task is not None: self.impl.log.debug('timer %r stop', self.iden) @@ -312,7 +304,7 @@ class virEventAsyncIOImpl(object): def schedule_ff_callback(self, iden: int, opaque: _T) -> None: '''Schedule a ff callback from one of the handles or timers''' - ensure_future(self._ff_callback(iden, opaque), loop=self.loop) + asyncio.ensure_future(self._ff_callback(iden, opaque), loop=self.loop) @asyncio.coroutine def _ff_callback(self, iden: int, opaque: _T) -> None: |