tornado icon indicating copy to clipboard operation
tornado copied to clipboard

Task was destroyed but it is pending

Open littleningmeng opened this issue 3 years ago • 4 comments

Hi, guys My code works fine in FastAPI, but got errors below in Tornado !

ERROR:asyncio:Task was destroyed but it is pending! source_traceback: Object created at (most recent call last): File "app.py", line 20, in tornado.ioloop.IOLoop.current().start() File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/platform/asyncio.py", line 132, in start self.asyncio_loop.run_forever() File "/home/qspace/python3.8.2/lib/python3.8/asyncio/base_events.py", line 570, in run_forever self._run_once() File "/home/qspace/python3.8.2/lib/python3.8/asyncio/base_events.py", line 1851, in _run_once handle._run() File "/home/qspace/python3.8.2/lib/python3.8/asyncio/events.py", line 81, in _run self._context.run(self._callback, *self._args) File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/ioloop.py", line 758, in _run_callback ret = callback() File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/stack_context.py", line 300, in null_wrapper return fn(*args, **kwargs) File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/gen.py", line 1147, in run yielded = self.gen.send(value) File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/http1connection.py", line 735, in _server_request_loop ret = yield conn.read_response(request_delegate) File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/http1connection.py", line 152, in read_response return self._read_message(delegate) File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/gen.py", line 346, in wrapper runner = Runner(result, future, yielded) File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/gen.py", line 1080, in init self.run() File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/gen.py", line 1147, in run yielded = self.gen.send(value) File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/http1connection.py", line 238, in _read_message delegate.finish() File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/routing.py", line 256, in finish self.delegate.finish() File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/web.py", line 2195, in finish self.execute() File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/web.py", line 2227, in execute self.handler._execute(transforms, *self.path_args, File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/gen.py", line 346, in wrapper runner = Runner(result, future, yielded) File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/gen.py", line 1078, in init if self.handle_yield(first_yielded): File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/gen.py", line 1221, in handle_yield self.future = convert_yielded(yielded) File "/home/qspace/python3.8.2/lib/python3.8/functools.py", line 874, in wrapper return dispatch(args[0].class)(*args, **kw) File "/home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/gen.py", line 1361, in convert_yielded return _wrap_awaitable(yielded) task: <Task pending name='Task-350' coro=<MainHandler.get() running at app.py:8> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7fa18ca65910>()] created at /home/qspace/python3.8.2/lib/python3.8/asyncio/base_events.py:422> cb=[IOLoop.add_future..() at /home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/ioloop.py:719] created at /home/qspace/.local/share/virtualenvs/qspace-BOV63HU7/lib/python3.8/site-packages/tornado/gen.py:1361>

littleningmeng avatar Aug 03 '21 10:08 littleningmeng

Could you please paste your code

Python-37 avatar Aug 04 '21 09:08 Python-37

Could you please paste your code

image

But in FastAPI, the same code works fine image

littleningmeng avatar Aug 04 '21 12:08 littleningmeng

Which version of Tornado are you using?

That snippet of code looks fine, but of course there's very little to it. The problem could be elsewhere. Are you trying to shut down your application or is it still running while this message is logged?

bdarnell avatar Aug 26 '21 18:08 bdarnell

The Tornado version is 6.1 The asyncio's Streams is used in the GetRpcWfsFile function And I did not do shutting down operations in it Also the implemention of GetRpcWfsFile are the same in both Tornado and FastAPI, but error occurred only in Tornado

littleningmeng avatar Aug 27 '21 07:08 littleningmeng