Skip to content

Read timeout when uploading large firmware #18

Closed
@qkaiser

Description

@qkaiser

I have a script that uploads a sample firmware (750MB) using the code provided in the client's README.

The whole firmware get sent to the server, then a read timeout happens:

python3 upload.py
[Tenant(id=UUID('REDACTED'), name='REDACTED')]
starting upload

Traceback (most recent call last):
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpx/_exceptions.py", line 326, in map_exceptions
    yield
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpx/_client.py", line 861, in _send_single_request
    ext={"timeout": timeout.as_dict()},
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpx/_transports/default.py", line 102, in request
    return self._pool.request(method, url, headers=headers, stream=stream, ext=ext)
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpcore/_sync/connection_pool.py", line 219, in request
    method, url, headers=headers, stream=stream, ext=ext
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpcore/_sync/connection.py", line 106, in request
    return self.connection.request(method, url, headers, stream, ext)
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpcore/_sync/http11.py", line 72, in request
    ) = self._receive_response(timeout)
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpcore/_sync/http11.py", line 133, in _receive_response
    event = self._receive_event(timeout)
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpcore/_sync/http11.py", line 172, in _receive_event
    data = self.socket.read(self.READ_NUM_BYTES, timeout)
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpcore/_backends/sync.py", line 62, in read
    return self.sock.recv(n)
  File "/usr/lib/python3.6/contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
    raise to_exc(exc) from None
httpcore.ReadTimeout: The read operation timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "upload.py", line 37, in <module>
    res = client.upload_firmware(metadata, firmware_path, enable_monitoring=False)
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/onekey_client/client.py", line 43, in wrapper
    return func(self, *args, **kwargs)
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/onekey_client/client.py", line 193, in upload_firmware
    res = self._post_with_token(upload_url, files={"firmware": path.open("rb")})
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/onekey_client/client.py", line 43, in wrapper
    return func(self, *args, **kwargs)
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/onekey_client/client.py", line 121, in _post_with_token
    return self._post(path, headers, **kwargs)
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/onekey_client/client.py", line 113, in _post
    response = self._client.post(path, headers=headers, **kwargs)
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpx/_client.py", line 999, in post
    timeout=timeout,
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpx/_client.py", line 729, in request
    request, auth=auth, allow_redirects=allow_redirects, timeout=timeout
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpx/_client.py", line 767, in send
    history=[],
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpx/_client.py", line 804, in _send_handling_auth
    history=history,
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpx/_client.py", line 832, in _send_handling_redirects
    response = self._send_single_request(request, timeout)
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpx/_client.py", line 861, in _send_single_request
    ext={"timeout": timeout.as_dict()},
  File "/usr/lib/python3.6/contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/qka/upload/.ve/lib/python3.6/site-packages/httpx/_exceptions.py", line 343, in map_exceptions
    raise mapped_exc(message, **kwargs) from exc  # type: ignore
httpx.ReadTimeout: The read operation timed out

On top of this, firmware objects are created even if the upload does not succeed, which means we need to change the name everytime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions