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).
In
FileHashStore
,thread
andmultiprocessing
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 amain
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).