Giter VIP home page Giter VIP logo

Comments (4)

vxgmichel avatar vxgmichel commented on June 10, 2024

Hi @hollymcr,

This happens because a client is connected but it has not sent its data yet. That means the handle_echo task is running, waiting for the data arrive. It turns out that closing the server does not cancel the pending client tasks. Actually it does not even track them:

    self._loop.create_task(res)

I found a related issue on bugs.python.org: issue 28212.

from asyncio-doc.

hollymcr avatar hollymcr commented on June 10, 2024

This happens because a client is connected but it has not sent its data yet.

To be clear, whether or not any data has been sent isn't the issue, just whether the connection is still open. In the example the connection is closed immediately after data is received but that wouldn't generally be the case in real use.

That means the handle_echo task is running, waiting for the data arrive. It turns out that closing the server does not cancel the pending client tasks. Actually it does not even track them

Does this mean that the example is correct but the bug is in the library?

What is the implication of not calling loop.close()?

from asyncio-doc.

vxgmichel avatar vxgmichel commented on June 10, 2024

To be clear, whether or not any data has been sent isn't the issue.

You're right, but it was the simplest way to reproduce your issue.

Actually, it can happen even if the connection has been closed. Consider the following handler:

async def handle_echo(reader, writer):
    writer.close()
    await asyncio.sleep(100)

Does this mean that the example is correct but the bug is in the library?

That is my opinion yes. I just checked and the problem still appear in v3.7.0b3.

What is the implication of not calling loop.close()?

Consider the following handler:

async def handle_echo(reader, writer):
    try:
        writer.close()
        await asyncio.sleep(100)
    finally:
        print('some cleanup')

If you comment out loop.close(), some cleanup is never going to run.

from asyncio-doc.

vstinner avatar vstinner commented on June 10, 2024

I shut down the project: #33

from asyncio-doc.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.