Skip to content

Add support for pickling Limiter #262

@JWCook

Description

@JWCook

In v4, the Limiter class has some unpicklable attributes (lock and _thread_local). This is relevant for multiprocessing, which pickles objects before passing them to worker processes. This worked in past versions, but currently raises errors like:

TypeError: cannot pickle '_thread.RLock' object

This could be done by implementing Limiter.__getstate__ and __setstate__ to remove and recreate these attributes (example: https://github.com/JWCook/requests-ratelimiter/pull/129/changes).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions