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

Add multiprocessing process locks & shared list #98

Closed
doulikecookiedough opened this issue May 28, 2024 · 1 comment
Closed

Add multiprocessing process locks & shared list #98

doulikecookiedough opened this issue May 28, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@doulikecookiedough
Copy link
Contributor

In Python, there are two paths to achieve concurrency/parallelism: the threading module and the multiprocessing module. Currently, only a threading lock is used when synchronizing the storing and deleting of objects, which is completely bypassed when using multiprocessing.

To Do:

  • Add a multiprocessing lock and respective shared list (to track what identifiers are locked) for storing and deleting objects and metadata.
  • Document how to use multiprocessing locks (e.g., setting up a global variable before calling HashStore).
    • Check to see if there is any other path to do this that may be simpler

Example Code:

reference_lock_mp = multiprocessing.Lock()
reference_locked_cids_mp = multiprocessing.Manager().list()  # Create a shared list

use_multiprocessing = os.getenv("USE_MULTIPROCESSING", "False") == "True"
    if use_multiprocessing:
        while cid in self.reference_locked_cids_mp:
            ...
@doulikecookiedough doulikecookiedough added the enhancement New feature or request label May 28, 2024
@doulikecookiedough
Copy link
Contributor Author

This has been completed via #103.

Documented how to switch HashStore from threading synchronization to multiprocessing. There may be a more elegant way to do this, but I feel this is good enough at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant