memory from transport buffer not freed after connection_lost
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- À clarifier
- Activité
- À l'abandon
- Stack technique
- python
- Domaine
- networking
Piste de recherche
Commencez par exécuter la reproduction Python fournie avec uvloop.new_event_loop, en observant d’abord la mémoire après la fermeture de la session telnet, puis en la comparant avec le runner asyncio standard. Suivez le tampon du transport et le chemin de connection_lost ; c’est terminé lorsque la mémoire est libérée après la déconnexion comme avec asyncio.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
- uvloop version: 0.17.0
- Python version: 3.11.4
- Platform: fedora 38
- Can you reproduce the bug with
PYTHONASYNCIODEBUGin env?: yes, with PYTHONASYNCIODEBUG=1 - Does uvloop behave differently from vanilla asyncio? How?: yes, keeps resident memory
If I flood transport.write() and then close the connection (e.g. having the client telnet session stop) the memory stays resident.
Under stock asyncio, the memory immediately is released.
To reproduce,
- start this program,
- watch it in top
- , telnet to port 8888,
- watch memory usage spike.
- close the telnet session,
- see that memory usage stays high.
- repeat this experiment with stock asyncio runner,
- the memory is freed immediately. after telnet session is closed
This test script is a malloc bomb, so make sure you watch memory closely or you will consume all the memory on your machine
#!/usr/bin/env python3
import asyncio
import uvloop
class EchoServerProtocol(asyncio.Protocol):
def __init__(self, on_connect, on_disconnect):
self.on_connect = on_connect
self.on_disconnect = on_disconnect
def connection_lost(self, transport):
print('Connection lost')
self.on_disconnect()
self.transport = None
def connection_made(self, transport):
self.on_connect(transport)
peername = transport.get_extra_info('peername')
print('Connection from {}'.format(peername))
self.transport = transport
def data_received(self, data):
message = data.decode()
print('Data received: {!r}'.format(message))
print('Send: {!r}'.format(message))
self.transport.write(data)
print('Close the client socket')
async def send_data(transport):
message = b'Hello World!' * 1000
while True:
transport.write(message)
await asyncio.sleep(0)
task = None
def on_connect(transport):
global task
task = asyncio.create_task(send_data(transport))
def on_disconnect():
global task
task.cancel()
async def start():
# Get a reference to the event loop as we plan to use
# low-level APIs.
loop = asyncio.get_running_loop()
server = await loop.create_server(
lambda: EchoServerProtocol(on_connect, on_disconnect),
'127.0.0.1',
8888,
)
async with server:
await server.serve_forever()
if __name__ == '__main__':
# with asyncio.Runner() as runner:
with asyncio.Runner(loop_factory=uvloop.new_event_loop) as runner:
runner.run(start())
- Langage dominant
- Cython
- Étoiles
- 11.9k
- Forks
- 615
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de MagicStack/uvloop
-
License not clear Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
MagicStack/uvloop#759 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
MagicStack/uvloop#741 · 2 réactions ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
MagicStack/uvloop#702 · 8 commentaires · 9 réactions ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
MagicStack/uvloop#766 ·
-
Directly constructed subprocess pipe protocols segfault when callbacks use a non-process owner Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 52/100
MagicStack/uvloop#765 ·
Toutes les issues de MagicStack/uvloop
Issues similaires
-
Browser (wasm) relay client cannot connect to relays whose URL has a trailing-dot FQDN hostname Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
n0-computer/iroh#4550 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
bytecodealliance/rustix#1689 · 2 commentaires ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
home-assistant/supervisor#7248 ·
-
bug cert blocker needs triage
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
project-chip/connectedhomeip#74373 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100