Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

threading.local support #698

Open
KRRT7 opened this issue Jan 24, 2025 · 0 comments
Open

threading.local support #698

KRRT7 opened this issue Jan 24, 2025 · 0 comments

Comments

@KRRT7
Copy link

KRRT7 commented Jan 24, 2025

MRE

import dill as pickle

import threading


import dill


def main():
    local = threading.local()

    print(dill.loads(pickle.dumps(local)))


if __name__ == "__main__":
    main()

error:

(scipy-dev) (base) krrt7@arm64-apple-darwin20 scipy % /Users/krrt7/miniforge3/envs/scipy-dev/bin/python /Users/krrt7/Desktop/work/scipy/MRE.py
Traceback (most recent call last):
  File "/Users/krrt7/Desktop/work/scipy/MRE.py", line 16, in <module>
    main()
  File "/Users/krrt7/Desktop/work/scipy/MRE.py", line 12, in main
    print(dill.loads(pickle.dumps(local)))
                     ^^^^^^^^^^^^^^^^^^^
  File "/Users/krrt7/miniforge3/envs/scipy-dev/lib/python3.12/site-packages/dill/_dill.py", line 288, in dumps
    dump(obj, file, protocol, byref, fmode, recurse, **kwds)#, strictio)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/krrt7/miniforge3/envs/scipy-dev/lib/python3.12/site-packages/dill/_dill.py", line 260, in dump
    Pickler(file, protocol, **_kwds).dump(obj)
  File "/Users/krrt7/miniforge3/envs/scipy-dev/lib/python3.12/site-packages/dill/_dill.py", line 428, in dump
    StockPickler.dump(self, obj)
  File "/Users/krrt7/miniforge3/envs/scipy-dev/lib/python3.12/pickle.py", line 484, in dump
    self.save(obj)
  File "/Users/krrt7/miniforge3/envs/scipy-dev/lib/python3.12/site-packages/dill/_dill.py", line 422, in save
    StockPickler.save(self, obj, save_persistent_id)
  File "/Users/krrt7/miniforge3/envs/scipy-dev/lib/python3.12/pickle.py", line 576, in save
    rv = reduce(self.proto)
         ^^^^^^^^^^^^^^^^^^
TypeError: cannot pickle '_thread._local' object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant