使用PDM上传Python包至PyPI时遭遇WriteTimeout超时错误的排查方案求助
使用PDM上传Python包至PyPI时遭遇WriteTimeout超时错误的排查方案求助
我最近在尝试用PDM把自己的Python软件(版本0.8.2)上传到PyPI时,一直碰到[WriteTimeout]: The write operation timed out的错误,但另一个配置几乎相同的项目却能正常上传,而且这个项目之前也成功上传过。我昨天和今天都试过多次,结果都是同一个项目失败,另一个成功。
PDM执行的输出如下:
[nix-shell:...]$ pdm publish Building sdist... Built sdist at .../flinventory-gui/dist/flinventory_gui-0.8.2.tar.gz Building wheel from sdist... Built wheel at .../flinventory-gui/dist/flinventory_gui-0.8.2-py3-none-any.whl Uploading flinventory_gui-0.8.2-py3-none-any.whl 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.9/41.9 MB • 00:00 • 1.7 GB/s See /home/<myuser>/.local/state/pdm/log/pdm-publish-1izbpvq6.log for detailed debug log. [WriteTimeout]: The write operation timed out WARNING: Add '-v' to see the detailed traceback
详细的调试日志如下:
Traceback (most recent call last): File "/nix/store/fh5pvazqpn19q9vi46aiwv1c8lvj7i15-python3.12-httpx-0.28.1/lib/python3.12/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions yield File "/nix/store/fh5pvazqpn19q9vi46aiwv1c8lvj7i15-python3.12-httpx-0.28.1/lib/python3.12/site-packages/httpx/_transports/default.py", line 250, in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/gmwf71m0vhbcsmpdgljhqd4x8ljixld1-python3.12-httpcore-1.0.9/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 256, in handle_request raise exc from None File "/nix/store/gmwf71m0vhbcsmpdgljhqd4x8ljixld1-python3.12-httpcore-1.0.9/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 236, in handle_request response = connection.handle_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/gmwf71m0vhbcsmpdgljhqd4x8ljixld1-python3.12-httpcore-1.0.9/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 103, in handle_request return self._connection.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/gmwf71m0vhbcsmpdgljhqd4x8ljixld1-python3.12-httpcore-1.0.9/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 136, in handle_request raise exc File "/nix/store/gmwf71m0vhbcsmpdgljhqd4x8ljixld1-python3.12-httpcore-1.0.9/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 88, in handle_request self._send_request_body(**kwargs) File "/nix/store/gmwf71m0vhbcsmpdgljhqd4x8ljixld1-python3.12-httpcore-1.0.9/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 159, in _send_request_body self._send_event(event, timeout=timeout) File "/nix/store/gmwf71m0vhbcsmpdgljhqd4x8ljixld1-python3.12-httpcore-1.0.9/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 166, in _send_event self._network_stream.write(bytes_to_send, timeout=timeout) File "/nix/store/gmwf71m0vhbcsmpdgljhqd4x8ljixld1-python3.12-httpcore-1.0.9/lib/python3.12/site-packages/httpcore/_backends/sync.py", line 135, in write with map_exceptions(exc_map): File "/nix/store/8w718rm43x7z73xhw9d6vh8s4snrq67h-python3-3.12.10/lib/python3.12/contextlib.py", line 158, in __exit__ self.gen.throw(value) File "/nix/store/gmwf71m0vhbcsmpdgljhqd4x8ljixld1-python3.12-httpcore-1.0.9/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions raise to_exc(exc) from exc httpcore.WriteTimeout: The write operation timed out The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/nix/store/n13h35gim2bbwi3qvinr8lvxx5p1n317-pdm-2.24.1/lib/python3.12/site-packages/pdm/termui.py", line 260, in logging yield logger File "/nix/store/n13h35gim2bbwi3qvinr8lvxx5p1n317-pdm-2.24.1/lib/python3.12/site-packages/pdm/cli/commands/publish/__init__.py", line 189, in handle resp = repository.upload(package) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/n13h35gim2bbwi3qvinr8lvxx5p1n317-pdm-2.24.1/lib/python3.12/site-packages/pdm/cli/commands/publish/repository.py", line 182, in upload resp = self.session.send(request, follow_redirects=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/fh5pvazqpn19q9vi46aiwv1c8lvj7i15-python3.12-httpx-0.28.1/lib/python3.12/site-packages/httpx/_client.py", line 914, in send response = self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/fh5pvazqpn19q9vi46aiwv1c8lvj7i15-python3.12-httpx-0.28.1/lib/python3.12/site-packages/httpx/_client.py", line 942, in _send_handling_auth response = self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/fh5pvazqpn19q9vi46aiwv1c8lvj7i15-python3.12-httpx-0.28.1/lib/python3.12/site-packages/httpx/_client.py", line 971, in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/fh5pvazqpn19q9vi46aiwv1c8lvj7i15-python3.12-httpx-0.28.1/lib/python3.12/site-packages/httpx/_client.py", line 1007, in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/fh5pvazqpn19q9vi46aiwv1c8lvj7i15-python3.12-httpx-0.28.1/lib/python3.12/site-packages/httpx/_transports/default.py", line 245, in handle_request with map_httpcore_exceptions(): File "/nix/store/8w718rm43x7z73xhw9d6vh8s4snrq67h-python3-3.12.10/lib/python3.12/contextlib.py", line 158, in __exit__ self.gen.throw(value) File "/nix/store/fh5pvazqpn19q9vi46aiwv1c8lvj7i15-python3.12-httpx-0.28.1/lib/python3.12/site-packages/httpx/_transports/default.py", line 123, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.WriteTimeout: The write operation timed out
我已经排除了PyPI全局故障的可能(因为另一个项目能正常上传),现在想请教大家,我可以从哪些方面入手排查这个问题?比如:
- 是否是这个包的大小问题?(这个包是41.9MB,另一个成功的包更小一些,但之前也上传过差不多大小的版本)
- PDM或依赖库(比如httpx/httpcore)的配置有没有需要调整的地方,比如超时时间?
- 有没有可能是PyPI对特定包名或版本的限制?
- 网络层面有没有什么需要检查的点?
麻烦大家给点建议,谢谢!
内容来源于stack exchange
相关产品推荐
相关产品推荐

