Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
3730a17a
Kaydet (Commit)
3730a17a
authored
Haz 15, 2012
tarafından
Richard Oudkerk
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #14059: Implement multiprocessing.Barrier
üst
a6bc4b4c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
92 additions
and
9 deletions
+92
-9
multiprocessing.rst
Doc/library/multiprocessing.rst
+18
-5
__init__.py
Lib/multiprocessing/__init__.py
+9
-2
__init__.py
Lib/multiprocessing/dummy/__init__.py
+2
-2
managers.py
Lib/multiprocessing/managers.py
+21
-0
synchronize.py
Lib/multiprocessing/synchronize.py
+40
-0
test_multiprocessing.py
Lib/test/test_multiprocessing.py
+0
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/library/multiprocessing.rst
Dosyayı görüntüle @
3730a17a
...
...
@@ -226,11 +226,11 @@ However, if you really do need to use some shared data then
holds Python objects and allows other processes to manipulate them using
proxies.
A manager returned by :func:`Manager` will support types
:class:`list`,
:class:`
dict`, :class:`Namespace`, :class:`Lock`, :class:`R
Lock`,
:class:`
Semaphore`, :class:`BoundedSemaphore`, :class:`Condition
`,
:class:`
Event`, :class:`Queue`, :class:`Value` and :class:`Array`. For
example, ::
A manager returned by :func:`Manager` will support types
:class:`
list`, :class:`dict`, :class:`Namespace`, :class:`
Lock`,
:class:`
RLock`, :class:`Semaphore`, :class:`BoundedSemaphore
`,
:class:`
Condition`, :class:`Event`, :class:`Barrier`,
:class:`Queue`, :class:`Value` and :class:`Array`. For
example, ::
from multiprocessing import Process, Manager
...
...
@@ -885,6 +885,12 @@ program as they are in a multithreaded program. See the documentation for
Note
that
one
can
also
create
synchronization
primitives
by
using
a
manager
object
--
see
:
ref
:`
multiprocessing
-
managers
`.
..
class
::
Barrier
(
parties
[,
action
[,
timeout
]])
A
barrier
object
:
a
clone
of
:
class
:`
threading
.
Barrier
`.
..
versionadded
::
3.3
..
class
::
BoundedSemaphore
([
value
])
A
bounded
semaphore
object
:
a
clone
of
:
class
:`
threading
.
BoundedSemaphore
`.
...
...
@@ -1280,6 +1286,13 @@ their parent process exits. The manager classes are defined in the
It
also
supports
creation
of
shared
lists
and
dictionaries
.
..
method
::
Barrier
(
parties
[,
action
[,
timeout
]])
Create
a
shared
:
class
:`
threading
.
Barrier
`
object
and
return
a
proxy
for
it
.
..
versionadded
::
3.3
..
method
::
BoundedSemaphore
([
value
])
Create
a
shared
:
class
:`
threading
.
BoundedSemaphore
`
object
and
return
a
...
...
Lib/multiprocessing/__init__.py
Dosyayı görüntüle @
3730a17a
...
...
@@ -23,8 +23,8 @@ __all__ = [
'Manager'
,
'Pipe'
,
'cpu_count'
,
'log_to_stderr'
,
'get_logger'
,
'allow_connection_pickling'
,
'BufferTooShort'
,
'TimeoutError'
,
'Lock'
,
'RLock'
,
'Semaphore'
,
'BoundedSemaphore'
,
'Condition'
,
'Event'
,
'
Queue'
,
'SimpleQueue'
,
'JoinableQueue'
,
'Pool'
,
'Value'
,
'Array
'
,
'RawValue'
,
'RawArray'
,
'SUBDEBUG'
,
'SUBWARNING'
,
'Event'
,
'
Barrier'
,
'Queue'
,
'SimpleQueue'
,
'JoinableQueue'
,
'Pool
'
,
'
Value'
,
'Array'
,
'
RawValue'
,
'RawArray'
,
'SUBDEBUG'
,
'SUBWARNING'
,
]
__author__
=
'R. Oudkerk (r.m.oudkerk@gmail.com)'
...
...
@@ -186,6 +186,13 @@ def Event():
from
multiprocessing.synchronize
import
Event
return
Event
()
def
Barrier
(
parties
,
action
=
None
,
timeout
=
None
):
'''
Returns a barrier object
'''
from
multiprocessing.synchronize
import
Barrier
return
Barrier
(
parties
,
action
,
timeout
)
def
Queue
(
maxsize
=
0
):
'''
Returns a queue object
...
...
Lib/multiprocessing/dummy/__init__.py
Dosyayı görüntüle @
3730a17a
...
...
@@ -35,7 +35,7 @@
__all__
=
[
'Process'
,
'current_process'
,
'active_children'
,
'freeze_support'
,
'Lock'
,
'RLock'
,
'Semaphore'
,
'BoundedSemaphore'
,
'Condition'
,
'Event'
,
'Queue'
,
'Manager'
,
'Pipe'
,
'Pool'
,
'JoinableQueue'
'Event'
,
'
Barrier'
,
'
Queue'
,
'Manager'
,
'Pipe'
,
'Pool'
,
'JoinableQueue'
]
#
...
...
@@ -49,7 +49,7 @@ import array
from
multiprocessing.dummy.connection
import
Pipe
from
threading
import
Lock
,
RLock
,
Semaphore
,
BoundedSemaphore
from
threading
import
Event
,
Condition
from
threading
import
Event
,
Condition
,
Barrier
from
queue
import
Queue
#
...
...
Lib/multiprocessing/managers.py
Dosyayı görüntüle @
3730a17a
...
...
@@ -993,6 +993,26 @@ class EventProxy(BaseProxy):
def
wait
(
self
,
timeout
=
None
):
return
self
.
_callmethod
(
'wait'
,
(
timeout
,))
class
BarrierProxy
(
BaseProxy
):
_exposed_
=
(
'__getattribute__'
,
'wait'
,
'abort'
,
'reset'
)
def
wait
(
self
,
timeout
=
None
):
return
self
.
_callmethod
(
'wait'
,
(
timeout
,))
def
abort
(
self
):
return
self
.
_callmethod
(
'abort'
)
def
reset
(
self
):
return
self
.
_callmethod
(
'reset'
)
@property
def
parties
(
self
):
return
self
.
_callmethod
(
'__getattribute__'
,
(
'parties'
,))
@property
def
n_waiting
(
self
):
return
self
.
_callmethod
(
'__getattribute__'
,
(
'n_waiting'
,))
@property
def
broken
(
self
):
return
self
.
_callmethod
(
'__getattribute__'
,
(
'broken'
,))
class
NamespaceProxy
(
BaseProxy
):
_exposed_
=
(
'__getattribute__'
,
'__setattr__'
,
'__delattr__'
)
def
__getattr__
(
self
,
key
):
...
...
@@ -1084,6 +1104,7 @@ SyncManager.register('Semaphore', threading.Semaphore, AcquirerProxy)
SyncManager
.
register
(
'BoundedSemaphore'
,
threading
.
BoundedSemaphore
,
AcquirerProxy
)
SyncManager
.
register
(
'Condition'
,
threading
.
Condition
,
ConditionProxy
)
SyncManager
.
register
(
'Barrier'
,
threading
.
Barrier
,
BarrierProxy
)
SyncManager
.
register
(
'Pool'
,
Pool
,
PoolProxy
)
SyncManager
.
register
(
'list'
,
list
,
ListProxy
)
SyncManager
.
register
(
'dict'
,
dict
,
DictProxy
)
...
...
Lib/multiprocessing/synchronize.py
Dosyayı görüntüle @
3730a17a
...
...
@@ -333,3 +333,43 @@ class Event(object):
return
False
finally
:
self
.
_cond
.
release
()
#
# Barrier
#
class
Barrier
(
threading
.
Barrier
):
def
__init__
(
self
,
parties
,
action
=
None
,
timeout
=
None
):
import
struct
from
multiprocessing.heap
import
BufferWrapper
wrapper
=
BufferWrapper
(
struct
.
calcsize
(
'i'
)
*
2
)
cond
=
Condition
()
self
.
__setstate__
((
parties
,
action
,
timeout
,
cond
,
wrapper
))
self
.
_state
=
0
self
.
_count
=
0
def
__setstate__
(
self
,
state
):
(
self
.
_parties
,
self
.
_action
,
self
.
_timeout
,
self
.
_cond
,
self
.
_wrapper
)
=
state
self
.
_array
=
self
.
_wrapper
.
create_memoryview
()
.
cast
(
'i'
)
def
__getstate__
(
self
):
return
(
self
.
_parties
,
self
.
_action
,
self
.
_timeout
,
self
.
_cond
,
self
.
_wrapper
)
@property
def
_state
(
self
):
return
self
.
_array
[
0
]
@_state.setter
def
_state
(
self
,
value
):
self
.
_array
[
0
]
=
value
@property
def
_count
(
self
):
return
self
.
_array
[
1
]
@_count.setter
def
_count
(
self
,
value
):
self
.
_array
[
1
]
=
value
Lib/test/test_multiprocessing.py
Dosyayı görüntüle @
3730a17a
This diff is collapsed.
Click to expand it.
Misc/NEWS
Dosyayı görüntüle @
3730a17a
...
...
@@ -21,6 +21,8 @@ Core and Builtins
Library
-------
- Issue #14059: Implement multiprocessing.Barrier.
- Issue #15061: The inappropriately named hmac.secure_compare has been
renamed to hmac.compare_digest, restricted to operating on bytes inputs
only and had its documentation updated to more accurately reflect both its
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment