Avoid global multiprocessing locks#617
Avoid global multiprocessing locks#617casperdcl merged 2 commits intotqdm:masterfrom mjstevens777:fix/multiprocessing-lock
Conversation
|
@casperdcl I think now it's the time to remove py26 from travis.ci. Anyway, it is no longer supported officially and it raises an compatibility error.. |
|
IHMO, maybe it's better to have a testcase for #611. |
Codecov Report
@@ Coverage Diff @@
## master #617 +/- ##
==========================================
+ Coverage 98.78% 98.93% +0.14%
==========================================
Files 10 10
Lines 743 750 +7
Branches 132 134 +2
==========================================
+ Hits 734 742 +8
+ Misses 5 4 -1
Partials 4 4 |
|
Sorry for the long delay. I have added a test. Python2.7 is failing because of a bug in requests/coveralls, but otherwise the tests are passing. Please let me know if there are any other changes you would like me to make. |
|
does it fix #611 ? Sorry don't have much time to look into everything. |
|
Yeah, it fixes the issue. Creating the multiprocessing.RLock when importing tqdm was what caused the error, and that no longer happens. |
|
@casperdcl I think this PL is important and worth being merged into master ASAP. |
|
yes been über busy, will take a look soon hopefully |
|
ping |
- Moving locks to class properties - Adding lazy initialization for multiprocessing locks
This addresses: > /opt/conda/lib/python3.6/multiprocessing/semaphore_tracker.py:143: UserWarning: semaphore_tracker: There appear to be 1 leaked semaphores to clean up at shutdown len(cache)) Reported in Project-MONAI/MONAI#1629 Here we adopt the approach in tqdm: tqdm/tqdm#617 to address the similar issues with PyTorch: tqdm/tqdm#611 but for our use case. A global set of locks is added to the class on first use. We also add a threading lock in addition to a multiprocessing lock.
This addresses: > /opt/conda/lib/python3.6/multiprocessing/semaphore_tracker.py:143: UserWarning: semaphore_tracker: There appear to be 1 leaked semaphores to clean up at shutdown len(cache)) Reported in Project-MONAI/MONAI#1629 Here we adopt the approach in tqdm: tqdm/tqdm#617 to address the similar issues with PyTorch: tqdm/tqdm#611 but for our use case. A global set of locks is added to the class on first use. We also add a threading lock in addition to a multiprocessing lock.
This addresses: > /opt/conda/lib/python3.6/multiprocessing/semaphore_tracker.py:143: UserWarning: semaphore_tracker: There appear to be 1 leaked semaphores to clean up at shutdown len(cache)) Reported in Project-MONAI/MONAI#1629 Here we adopt the approach in tqdm: tqdm/tqdm#617 to address the similar issues with PyTorch: tqdm/tqdm#611 but for our use case. A global set of locks is added to the class on first use. We also add a threading lock in addition to a multiprocessing lock.
This addresses: > /opt/conda/lib/python3.6/multiprocessing/semaphore_tracker.py:143: UserWarning: semaphore_tracker: There appear to be 1 leaked semaphores to clean up at shutdown len(cache)) Reported in Project-MONAI/MONAI#1629 Here we adopt the approach in tqdm: tqdm/tqdm#617 to address the similar issues with PyTorch: tqdm/tqdm#611 but for our use case. A global set of locks is added to the class on first use.
This addresses: > /opt/conda/lib/python3.6/multiprocessing/semaphore_tracker.py:143: UserWarning: semaphore_tracker: There appear to be 1 leaked semaphores to clean up at shutdown len(cache)) Reported in Project-MONAI/MONAI#1629 Here we adopt the approach in tqdm: tqdm/tqdm#617 to address the similar issues with PyTorch: tqdm/tqdm#611 but for our use case. A global set of locks is added to the class on first use.
Fixes #611
The current behavior of initializing a multiprocessing lock is undocumented behavior. The main documentation says to feed in a lock explicitly for windows compatibility.
read the known issues
environment, where applicable:
Here is how this change affects the following use cases:
pool.imapor similar methods.spawn, create a progress bar in the main thread, run a multiprocessing pooltqdm.set_lock