aio-libs / aio-libs/aioftp

Halting a stream renders the connection unusable

Abierto
#201 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
211
Forks
63
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I am trying to follow the documentation to abort a file transfer early when i read a certain line: https://aioftp.aio-libs.org/client_tutorial.html#advanced-download-and-upload-abort-restart

```import asyncio
import aioftp

async def main(files):
async with aioftp.Client.context('127.0.0.1') as client:

for fn in files:
print("Streaming", fn)
stream = await client.download_stream(fn)
async for line in stream.iter_by_line():
await client.abort()
stream.close()
break
else:
await stream.finish()

if __name__ == '__main__':
asyncio.run(main(['a.txt', 'b.txt']))
```

However, the connection is not usable anymore after the first file has been transferred.
The script above returns the following Exception:

> $ python3 ../ftp_bug.py
> Streaming a.txt
> Streaming b.txt
> Traceback (most recent call last):
> File "/home/ed/Desktop/Log/app/../ftp_bug.py", line 17, in
> asyncio.run(main(['a.txt', 'b.txt']))
> ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib64/python3.14/asyncio/runners.py", line 204, in run
> return runner.run(main)
> ~~~~~~~~~~^^^^^^
> File "/usr/lib64/python3.14/asyncio/runners.py", line 127, in run
> return self._loop.run_until_complete(task)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
> File "/usr/lib64/python3.14/asyncio/base_events.py", line 719, in run_until_complete
> return future.result()
> ~~~~~~~~~~~~~^^
> File "/home/ed/Desktop/Log/app/../ftp_bug.py", line 8, in main
> stream = await client.download_stream(fn)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/home/ed/.local/lib/python3.14/site-packages/aioftp/client.py", line 1400, in get_stream
> reader, writer = await self.get_passive_connection(conn_type)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/home/ed/.local/lib/python3.14/site-packages/aioftp/client.py", line 1356, in get_passive_connection
> await self.command("TYPE " + conn_type, "200")
> File "/home/ed/.local/lib/python3.14/site-packages/aioftp/client.py", line 401, in command
> self.check_codes(expected_codes, code, info)
> ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/home/ed/.local/lib/python3.14/site-packages/aioftp/client.py", line 331, in check_codes
> raise errors.StatusCodeError(expected_codes, received_code, info)
> aioftp.errors.StatusCodeError: Waiting for ('200',) but got 225 [' No transfer to abort.']
>

Am i doing anything wrong?

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.