Skip to content

Commit

Permalink
Add Lock to multiprocessing (#1976) (#1996)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
(cherry picked from commit 635a211)

Co-authored-by: Dani Alcala <112832187+clavedeluna@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and clavedeluna committed Jan 31, 2023
1 parent e18d663 commit 2cdf6ce
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Release date: TBA

Closes PyCQA/pylint#8074

* Add ``Lock`` to the ``multiprocessing`` brain.

Closes PyCQA/pylint#3313


What's New in astroid 2.13.3?
=============================
Expand Down
1 change: 1 addition & 0 deletions astroid/brain/brain_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class SyncManager(object):
Queue = JoinableQueue = queue.Queue
Event = threading.Event
RLock = threading.RLock
Lock = threading.Lock
BoundedSemaphore = threading.BoundedSemaphore
Condition = threading.Condition
Barrier = threading.Barrier
Expand Down
2 changes: 1 addition & 1 deletion astroid/brain/brain_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __exit__(self, *args):
def locked(self):
return False
def Lock():
def Lock(*args, **kwargs):
return lock()
"""
)
Expand Down
5 changes: 5 additions & 0 deletions tests/unittest_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ def test_multiprocessing_manager(self) -> None:
joinable_queue = manager.JoinableQueue()
event = manager.Event()
rlock = manager.RLock()
lock = manager.Lock()
bounded_semaphore = manager.BoundedSemaphore()
condition = manager.Condition()
barrier = manager.Barrier()
Expand All @@ -736,6 +737,10 @@ def test_multiprocessing_manager(self) -> None:
rlock_name = "threading._RLock"
self.assertEqual(rlock.qname(), rlock_name)

lock = next(module["lock"].infer())
lock_name = "threading.lock"
self.assertEqual(lock.qname(), lock_name)

bounded_semaphore = next(module["bounded_semaphore"].infer())
semaphore_name = "threading.BoundedSemaphore"
self.assertEqual(bounded_semaphore.qname(), semaphore_name)
Expand Down

0 comments on commit 2cdf6ce

Please sign in to comment.