question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Task was destroyed but it is pending!

See original GitHub issue

I’m running a pretty simple quart app with hypercorn on a RHEL7 linux server. quart = 0.10.0 hypercorn = 0.9.0

I keep seeing these messages printed to standard out randomly every couple requests.

Task was destroyed but it is pending!
task: <Task pending coro=<ProtocolWrapper.send_task() done, defined at /root/.local/share/virtualenvs/atomix-Zh2dG3yU/lib/python3.7/site-packages/hypercorn/protocol/__init__.py:58> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f08fc3db1d0>()]>>
Task was destroyed but it is pending!
task: <Task pending coro=<ProtocolWrapper.send_task() done, defined at /root/.local/share/virtualenvs/atomix-Zh2dG3yU/lib/python3.7/site-packages/hypercorn/protocol/__init__.py:58> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f08f55188d0>()]>>

I’m pretty sure it has to do with hypercorn because I don’t see the messages when I run the app using app.run(…). I’m having trouble narrowing down the problem anymore than that… Is anyone else seeing these messages?

Every once in a while I have a json request fail. The response body is mysteriously empty. The content-length is set to the correct non 0 value but nothing is in the body. I’m not sure if its related to this or not.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
pgjonescommented, Mar 23, 2020

Ok, so I’m now confident that 0.9.3 has fixed this.

2reactions
bhimesubercommented, Mar 3, 2020

Well, that didn’t take long:

2020-03-03 08:00:03,542 :: ERROR :: Task was destroyed but it is pending!
task: <Task pending name='Task-40' coro=<ProtocolWrapper.send_task() done, defined at /home/bhimes/Gits/hardware-tooling/venvhypercorn/lib/python3.8/site-packages/hypercorn/protocol/__init__.py:58> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f33554e5eb0>()]>>

Started up the hypercorn server (running Quart), clicked around a few of the links in my web app, was working fine. Walked away from my computer and made myself coffee. Came back, clicked another link (same session, browser, window, etc.), instantly this. Note that the page still loaded fine (they really always do), but yet still getting that error in the log.

EDIT: Confirmed that this dev version does include 1e350e4. From /home/bhimes/Gits/hardware-tooling/venvhypercorn/lib/python3.8/site-packages/hypercorn/protocol/h2.py

    async def _close_stream(self, stream_id: int) -> None:
        if stream_id in self.streams:
            stream = self.streams.pop(stream_id)
            await stream.handle(StreamClosed(stream_id=stream_id))
            await self.has_data.set()

These are all h2 in Chrome btw.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Please explain "Task was destroyed but it is pending!" after ...
The problem comes from closing the loop immediately after cancelling the tasks. As the cancel() docs state.
Read more >
Task was destroyed but it is pending · Issue #1634 - GitHub
Problem with celery task, that aggregates media from some channels. Previously i tried "sync" version of TelethonClient and got same errors.
Read more >
Task was destroyed but it is pending! - Questions and Help
I'm having a hard time trying to avoid the following issue: Task was destroyed but it is pending! This is related to the...
Read more >
Common Mistakes Using Python3 asyncio
3 Task was destroyed but it is pending! The cause of this problem is that the EventLoop closed right after canceling pending tasks....
Read more >
ERROR Task was destroyed but it is pending! - Google Groups
System check identified no issues (0 silenced). ... To quit the server, press Control+C. ... ERROR Task was destroyed but it is pending!...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found