DataONEorg / hashstore

HashStore, a hash-based object store for DataONE data packages
Apache License 2.0
1 stars 1 forks source link

HashStore Class Variables Causing Conflicts Upon Import #119

Closed doulikecookiedough closed 2 weeks ago

doulikecookiedough commented 2 weeks ago

In FileHashStore, thread and multiprocessing variables (threading.Lock(), multiprocessing.Lock(), etc.) are declared outside of the __init__ process. This can create conflicts upon importing hashstore as a library, and not part of a main method in a python program (which can guard against top-level code being executed in new processes unintentionally).

This is especially true with the multiprocessing module due to the nature of how processes are spawned and initialized. Each new spawn process will re-import the module (recursive import).

These should not be declared as class variables, but determined upon instantiation instead so that it does not interfere with the initial set-up phase of the Python interpreter and its environment (ex. move them to the __init__ method).

doulikecookiedough commented 2 weeks ago

This has been resolved via Bug-119: hashstore Library Import Conflict