tornado icon indicating copy to clipboard operation
tornado copied to clipboard

Problem with transform tornado Future into Asyncio Future

Open bucketzxm opened this issue 10 years ago • 1 comments

I have a function like this:

@asyncio.coroutine
def fetchDatabase():
    ans = self._httpClient.fetch(request, callback, raise_error)
    ans = yield from asyncio.ensure_future( platform.asyncio.to_asyncio_future(ans))
    return ans

I call this function by using:

response = yield from fetchDatabase()

In tornado 4.1 , this can work properly and I got the http response, but in tornado 4.4 I got an error which complain about

File "/opt/lib/python3.5/asyncio/futures.py", line 362, in __iter__
    assert self.done(), "yield from wasn't used with future"
AssertionError: yield from wasn't used with future

I am not sure what is the correct way when I want to use asyncio library to yield from tornado Future...

bucketzxm avatar Nov 10 '16 06:11 bucketzxm

Hi all,

I have installed async loop by using AsyncIOMainLoop().install() .. but still have this problem

thanks,

bucketzxm avatar Nov 10 '16 09:11 bucketzxm