Skip to content

Conversation

@carmenbianca
Copy link
Contributor

Under some circumstances (see xonsh/xonsh#3907) a DeprecationWarning would be printed. This is because of passing coroutine objects directly to asyncio.wait(), which is confusing behaviour that has been deprecated.

python/cpython#9543 gives information on how to refactor code that uses the deprecated method.

Fixes xonsh/xonsh#3907

Under some circumstances (see
<xonsh/xonsh#3907>) a DeprecationWarning would
be printed. This is because of passing coroutine objects directly to
asyncio.wait(), which is confusing behaviour that has been deprecated.

<python/cpython#9543> gives information on how
to refactor code that uses the deprecated method.

Signed-off-by: Carmen Bianca Bakker <[email protected]>
@carmenbianca
Copy link
Contributor Author

Ah… Broken under 3.6. asyncio.create_task was only introduced in 3.7.

Not sure what the preferred method of fixing this is. This could possibly do it if I'm not mistaken:

try:
    from asyncio import create_task
except ImportError:
    create_task = lambda x: x

But that's obviously a bit hacky. Happy to take input :)

@jonathanslenders
Copy link
Member

Can we use asyncio.ensure_future() instead of asyncio.create_task()?

create_task() is not available for Python <3.7.

Signed-off-by: Carmen Bianca Bakker <[email protected]>
@carmenbianca
Copy link
Contributor Author

@jonathanslenders That appears to work, although the documentation for ensure_future() is esoteric magic to me.

@jonathanslenders jonathanslenders merged commit 80dbc3f into prompt-toolkit:master Dec 3, 2020
@jonathanslenders
Copy link
Member

Thank you @carmenbianca !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeprecationWarning: The explicit passing of coroutine objects to asyncio.wait...

2 participants