Skip to content

httpx Multipart Message not working #8

Description

@nixwieweg

I have some problems in using httpx async with Multipart POST requests. I don't have the same problem with the requests backend. The problem seems to be the "merge_dict" which is only done on httpx:

  File "/home/debian/run/run.py", line 261, in do_upload
    logging.info(await s.post_file(other_image, ("image.swi", f, "application/octet-stream")))
  File "/home/debian/run/.venv/lib/python3.9/site-packages/decorest/session.py", line 155, in invoker
    return await getattr(self.__client, name)(*args, **kwargs)
  File "/home/debian/run/.venv/lib/python3.9/site-packages/decorest/POST.py", line 42, in async_post_decorator
    return await super(POST,
  File "/home/debian/run/.venv/lib/python3.9/site-packages/decorest/decorators.py", line 206, in call_async
    http_request = HttpRequest(func, self.path_template, args, kwargs)
  File "/home/debian/run/.venv/lib/python3.9/site-packages/decorest/request.py", line 284, in __init__
    merge_dicts(self.kwargs, self.rest_client.client_args_)
  File "/home/debian/run/.venv/lib/python3.9/site-packages/decorest/utils.py", line 132, in merge_dicts
    result = copy.deepcopy(dictionary)
  File "/usr/lib/python3.9/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python3.9/copy.py", line 230, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib/python3.9/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python3.9/copy.py", line 230, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib/python3.9/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python3.9/copy.py", line 210, in _deepcopy_tuple
    y = [deepcopy(a, memo) for a in x]
  File "/usr/lib/python3.9/copy.py", line 210, in <listcomp>
    y = [deepcopy(a, memo) for a in x]
  File "/usr/lib/python3.9/copy.py", line 161, in deepcopy
    rv = reductor(4)
TypeError: cannot pickle '_io.BufferedReader' object

If I replace the :

   merge_dicts(self.kwargs, self.rest_client.client_args_)

in request.py by

   for arg, value in self.rest_client.client_args_.items():
         self.kwargs[arg]= value

it works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions