Giter Club home page Giter Club logo

Comments (1)

jonathanabila avatar jonathanabila commented on May 27, 2024
    return merge({}, self._custom_request_kwargs, kwargs)
  File "/opt/python/mergedeep/mergedeep.py", line 106, in merge
    return reduce(partial(_deepmerge, strategy=strategy), sources, destination)
  File "/opt/python/mergedeep/mergedeep.py", line 94, in _deepmerge
    dst[key] = deepcopy(src[key])
  File "/var/lang/lib/python3.8/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/var/lang/lib/python3.8/copy.py", line 270, in _reconstruct
    state = deepcopy(state, memo)
  File "/var/lang/lib/python3.8/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/var/lang/lib/python3.8/copy.py", line 230, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/var/lang/lib/python3.8/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/var/lang/lib/python3.8/copy.py", line 237, in _deepcopy_method
    return type(x)(x.__func__, deepcopy(x.__self__, memo))
  File "/var/lang/lib/python3.8/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/var/lang/lib/python3.8/copy.py", line 270, in _reconstruct
    state = deepcopy(state, memo)
  File "/var/lang/lib/python3.8/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/var/lang/lib/python3.8/copy.py", line 230, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/var/lang/lib/python3.8/copy.py", line 161, in deepcopy
    rv = reductor(4)
TypeError: cannot pickle 'module' object

Probably not very useful, but it's happening inside a multithread context.

I tried to replicate the same scenario in a test, but it didn't work:

    def test__merge_kwargs(self, requests_mock):
        """
        Normally, private methods shouldn't have tests, however this one had problems in production,
        so now we have tests for it.
        """
        def auth_method(client, method, uri, headers, body):
            body = add_params_to_qs(
                body or "",
                [
                    ("client_id", client.client_id),
                    ("client_secret", client.client_secret or ""),
                ],
            )
            if "Content-Length" in headers:
                headers["Content-Length"] = str(len(body))

            headers["Content-Type"] = "application/x-www-form-urlencoded"
            return uri, headers, body

        client = OAuthClient("client_id", "client_secret", token_endpoint_auth_method="auth_method")
        client.register_client_auth_method(("auth_method", auth_method))

        requests_mock.post(self.url, json={"refresh_token": "123123"})

        client.refresh_token(self.url, refresh_token="123123")

Maybe be a shallow copy would work here too, I couldn't pinpoint the problem, but it seems to be the same issue with threads.

from mergedeep.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.