Skip to content

_ProactorBasePipeTransport.abort() after _ProactorBasePipeTransport.close() does not cancel writes #88594

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

Closed
graingert mannequin opened this issue Jun 15, 2021 · 6 comments
Labels
3.10 only security fixes 3.11 only security fixes 3.12 only security fixes topic-asyncio

Comments

@graingert
Copy link
Mannequin

graingert mannequin commented Jun 15, 2021

BPO 44428
Nosy @gvanrossum, @asvetlov, @ambv, @1st1, @graingert

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-06-15.21:00:19.644>
labels = ['3.8', '3.9', '3.10', 'expert-asyncio']
title = '_ProactorBasePipeTransport.abort() after _ProactorBasePipeTransport.close() does not cancel writes'
updated_at = <Date 2021-07-12.16:40:18.078>
user = 'https://github.com/graingert'

bugs.python.org fields:

activity = <Date 2021-07-12.16:40:18.078>
actor = 'graingert'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['asyncio']
creation = <Date 2021-06-15.21:00:19.644>
creator = 'graingert'
dependencies = []
files = []
hgrepos = []
issue_num = 44428
keywords = []
message_count = 2.0
messages = ['395896', '396558']
nosy_count = 5.0
nosy_names = ['gvanrossum', 'asvetlov', 'lukasz.langa', 'yselivanov', 'graingert']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue44428'
versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

@graingert
Copy link
Mannequin Author

graingert mannequin commented Jun 15, 2021

demo program:

import asyncio
import socket
import threading

async def amain():
    family = socket.AddressFamily.AF_INET
    sock = socket.socket(family, socket.SOCK_STREAM)
    sock.settimeout(1)
    sock.bind(('localhost', 0))
    sock.listen()
    host, port = sock.getsockname()[:2]

    event = threading.Event()

    def serve():
        client, _ = sock.accept()
        with client:
            client.recv(1)
            event.wait()

    t = threading.Thread(target=serve, daemon=True)
    t.start()

    reader, writer = await asyncio.open_connection(host=host, port=port)
    try:
        while True:
            writer.write(b"\x00" * 4096 * 682 * 2)
            await asyncio.wait_for(writer.drain(), 2)
            print("wrote")
    except asyncio.TimeoutError:
        print("timed out")

    writer.close()
    await asyncio.sleep(0)
    writer.transport.abort()
    print("waiting close")
    await writer.wait_closed()  # never finishes on ProactorEventLoop
    print("closed")
    event.set()
    t.join()

asyncio.run(amain())

it looks like it was fixed for the selector eventloop in 2546a17

but not for the proactor https://github.com/python/cpython/blame/8fe57aacc7bf9d9af84803b69dbb1d66597934c6/Lib/asyncio/proactor_events.py#L140

@graingert graingert mannequin added 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes topic-asyncio labels Jun 15, 2021
@graingert
Copy link
Mannequin Author

graingert mannequin commented Jun 26, 2021

nosying the author of the selector_events fix

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@kumaraditya303
Copy link
Contributor

@gvanrossum Do you recall the details as you fixed the selector event loop race ?

@kumaraditya303 kumaraditya303 added 3.11 only security fixes 3.12 only security fixes and removed 3.9 only security fixes 3.8 (EOL) end of life labels Jul 9, 2022
@gvanrossum
Copy link
Member

Sorry, you're on your own here. I have no recollection of this fix.

@ezio-melotti ezio-melotti moved this to Todo in asyncio Jul 17, 2022
@kumaraditya303
Copy link
Contributor

Duplicate of #89237

@kumaraditya303 kumaraditya303 marked this as a duplicate of #89237 Oct 23, 2022
@kumaraditya303 kumaraditya303 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2022
Repository owner moved this from Todo to Done in asyncio Oct 23, 2022
@kumaraditya303
Copy link
Contributor

#98572 fixes this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes 3.11 only security fixes 3.12 only security fixes topic-asyncio
Projects
Status: Done
Development

No branches or pull requests

2 participants