summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-01-31 13:54:05 +0100
committerGitHub <noreply@github.com>2023-01-31 13:54:05 +0100
commit2cdf6cef10ab70495522d09046f4ee0ca5484f9f (patch)
treea0517380415286a8181be45617182680dcb3c086
parente18d6637a54163246585fcc6e1d09e1431b2b417 (diff)
downloadastroid-git-2cdf6cef10ab70495522d09046f4ee0ca5484f9f.tar.gz
Add Lock to multiprocessing (#1976) (#1996)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> (cherry picked from commit 635a211296ae8dbafbd9b94b56fe5472f7534c8a) Co-authored-by: Dani Alcala <112832187+clavedeluna@users.noreply.github.com>
-rw-r--r--ChangeLog4
-rw-r--r--astroid/brain/brain_multiprocessing.py1
-rw-r--r--astroid/brain/brain_threading.py2
-rw-r--r--tests/unittest_brain.py5
4 files changed, 11 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b1fc4df..82871c14 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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?
=============================
diff --git a/astroid/brain/brain_multiprocessing.py b/astroid/brain/brain_multiprocessing.py
index fc98a06c..c349bbef 100644
--- a/astroid/brain/brain_multiprocessing.py
+++ b/astroid/brain/brain_multiprocessing.py
@@ -78,6 +78,7 @@ def _multiprocessing_managers_transform():
Queue = JoinableQueue = queue.Queue
Event = threading.Event
RLock = threading.RLock
+ Lock = threading.Lock
BoundedSemaphore = threading.BoundedSemaphore
Condition = threading.Condition
Barrier = threading.Barrier
diff --git a/astroid/brain/brain_threading.py b/astroid/brain/brain_threading.py
index a85055d8..061b11fc 100644
--- a/astroid/brain/brain_threading.py
+++ b/astroid/brain/brain_threading.py
@@ -22,7 +22,7 @@ def _thread_transform():
def locked(self):
return False
- def Lock():
+ def Lock(*args, **kwargs):
return lock()
"""
)
diff --git a/tests/unittest_brain.py b/tests/unittest_brain.py
index 0ffccb35..30594c38 100644
--- a/tests/unittest_brain.py
+++ b/tests/unittest_brain.py
@@ -711,6 +711,7 @@ class MultiprocessingBrainTest(unittest.TestCase):
joinable_queue = manager.JoinableQueue()
event = manager.Event()
rlock = manager.RLock()
+ lock = manager.Lock()
bounded_semaphore = manager.BoundedSemaphore()
condition = manager.Condition()
barrier = manager.Barrier()
@@ -736,6 +737,10 @@ class MultiprocessingBrainTest(unittest.TestCase):
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)