On 06/27/2018 07:50 AM, Andrea Bolognani wrote:
On Mon, 2018-06-25 at 14:35 -0400, Cole Robinson wrote:
[...]
> -try:
> - from asyncio import ensure_future
> -except ImportError:
> - from asyncio import async as ensure_future
> +# python < 3.4.4: we want 'async'
> +# python >= 3.4.4 < 3.7, we want 'ensure_future'
> +# python >= 3.7, 'async' is a reserved keyword, so we can't import
it
> +ensure_future = getattr(asyncio, "ensure_future", None)
> +if not ensure_future:
> + ensure_future = getattr(asyncio, "async")
Python is not exactly my forte, but the above makes sense to me
and it stood up to some testing across all platforms supported by
libvirt, so
Reviewed-by: Andrea Bolognani <abologna(a)redhat.com>
One nit is that the comment above the code doesn't IMHO describe
the situation properly: I would have worded it along the lines of
# 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
I leave it up to you whether or not you want to reword the comment.
I used your comment and pushed it now
Thanks,
Cole