aio-libs / aio-libs/aioftp

Halting a stream renders the connection unusable

未關閉
#201 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
211
分支
63
PR 合併指標
30 天內沒有已合併 PR

描述

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?

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。