New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap concurrent.futures Future in polling function #467
Conversation
wrap concurrent future
@minrk could you help review this one liner? I think could be a quite severe bug with a simple fix. I'm not so confident about these things even though I learned a lot working with the async in some PRs before. |
Yup, this is right! Background: tornado A bit about why we have this: It bothers me perhaps more than it should that:
|
Thank you @ondave for reporting and fixing this issue!!! 🎉 ❤️! @minrk is this a consequence of jupyterhub/jupyterhub#3242, which also mean it would only influence jupyterhub>=1.3.0 ? Should something be patched in JupyterHub itself following this? |
Close. It should only be relevant within the given function, so I'm pretty sure this was caused by #444, which made the same switch on this particular method. Take for example: from concurrent.futures import ThreadPoolExecutor
from tornado import gen, ioloop
pool = ThreadPoolExecutor(1)
@gen.coroutine
def gen_coroutine():
return (yield pool.submit(lambda: "tornado ok"))
async def async_def():
return (await pool.submit(lambda: "asyncio ok"))
async def main():
print("tornado?")
print(await gen_coroutine())
print("asyncio?")
print(await async_def())
if __name__ == "__main__":
ioloop.IOLoop.current().run_sync(main) In this script, the tornado implementation can yield a c.f.Future and the async def can't, but the outer JupyterHub has its own compatibility layer in |
Cannot await a concurrent.futures Future, so easiest fix is to wrap with asyncio.wrap_future
Closes #466, a bug influencing 0.14.0 and 0.14.1 I think - Edit by @consideRatio.