summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDani Alcala <112832187+clavedeluna@users.noreply.github.com>2023-01-31 09:44:44 -0300
committerGitHub <noreply@github.com>2023-01-31 13:44:44 +0100
commit635a211296ae8dbafbd9b94b56fe5472f7534c8a (patch)
treeccd63e37ece7808be2fefdb42b56001ff4eaf4bc
parenta31da6fe388ad98cca51b734e3201d78d717c68c (diff)
downloadastroid-git-635a211296ae8dbafbd9b94b56fe5472f7534c8a.tar.gz
Add Lock to multiprocessing (#1976)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> Co-authored-by: Marc Mueller <30130371+cdce8p@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 5a2c18b2..42067ad1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,6 +23,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)