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
ac38571f
Kaydet (Commit)
ac38571f
authored
Haz 18, 2012
tarafından
Richard Oudkerk
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #15064: Make BaseManager.__enter__() start server if necessary.
üst
9c1feb88
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
9 deletions
+31
-9
multiprocessing.rst
Doc/library/multiprocessing.rst
+8
-3
managers.py
Lib/multiprocessing/managers.py
+3
-0
test_multiprocessing.py
Lib/test/test_multiprocessing.py
+20
-6
No files found.
Doc/library/multiprocessing.rst
Dosyayı görüntüle @
ac38571f
...
@@ -1281,9 +1281,14 @@ their parent process exits. The manager classes are defined in the
...
@@ -1281,9 +1281,14 @@ their parent process exits. The manager classes are defined in the
The
address
used
by
the
manager
.
The
address
used
by
the
manager
.
Manager
objects
support
the
context
manager
protocol
--
see
..
versionchanged
::
3.3
:
ref
:`
typecontextmanager
`.
:
meth
:`
__enter__
`
returns
the
Manager
objects
support
the
context
manager
protocol
--
see
manager
object
,
and
:
meth
:`
__exit__
`
calls
:
meth
:`
shutdown
`.
:
ref
:`
typecontextmanager
`.
:
meth
:`
__enter__
`
starts
the
server
process
(
if
it
has
not
already
started
)
and
then
returns
the
manager
object
.
:
meth
:`
__exit__
`
calls
:
meth
:`
shutdown
`.
In
previous
versions
:
meth
:`
__enter__
`
did
not
start
the
manager
's server process if it was not already started.
.. class:: SyncManager
.. class:: SyncManager
...
...
Lib/multiprocessing/managers.py
Dosyayı görüntüle @
ac38571f
...
@@ -561,6 +561,9 @@ class BaseManager(object):
...
@@ -561,6 +561,9 @@ class BaseManager(object):
conn
.
close
()
conn
.
close
()
def
__enter__
(
self
):
def
__enter__
(
self
):
if
self
.
_state
.
value
==
State
.
INITIAL
:
self
.
start
()
assert
self
.
_state
.
value
==
State
.
STARTED
return
self
return
self
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
...
...
Lib/test/test_multiprocessing.py
Dosyayı görüntüle @
ac38571f
...
@@ -1888,7 +1888,27 @@ class _TestMyManager(BaseTestCase):
...
@@ -1888,7 +1888,27 @@ class _TestMyManager(BaseTestCase):
def
test_mymanager
(
self
):
def
test_mymanager
(
self
):
manager
=
MyManager
()
manager
=
MyManager
()
manager
.
start
()
manager
.
start
()
self
.
common
(
manager
)
manager
.
shutdown
()
# If the manager process exited cleanly then the exitcode
# will be zero. Otherwise (after a short timeout)
# terminate() is used, resulting in an exitcode of -SIGTERM.
self
.
assertEqual
(
manager
.
_process
.
exitcode
,
0
)
def
test_mymanager_context
(
self
):
with
MyManager
()
as
manager
:
self
.
common
(
manager
)
self
.
assertEqual
(
manager
.
_process
.
exitcode
,
0
)
def
test_mymanager_context_prestarted
(
self
):
manager
=
MyManager
()
manager
.
start
()
with
manager
:
self
.
common
(
manager
)
self
.
assertEqual
(
manager
.
_process
.
exitcode
,
0
)
def
common
(
self
,
manager
):
foo
=
manager
.
Foo
()
foo
=
manager
.
Foo
()
bar
=
manager
.
Bar
()
bar
=
manager
.
Bar
()
baz
=
manager
.
baz
()
baz
=
manager
.
baz
()
...
@@ -1911,12 +1931,6 @@ class _TestMyManager(BaseTestCase):
...
@@ -1911,12 +1931,6 @@ class _TestMyManager(BaseTestCase):
self
.
assertEqual
(
list
(
baz
),
[
i
*
i
for
i
in
range
(
10
)])
self
.
assertEqual
(
list
(
baz
),
[
i
*
i
for
i
in
range
(
10
)])
manager
.
shutdown
()
# If the manager process exited cleanly then the exitcode
# will be zero. Otherwise (after a short timeout)
# terminate() is used, resulting in an exitcode of -SIGTERM.
self
.
assertEqual
(
manager
.
_process
.
exitcode
,
0
)
#
#
# Test of connecting to a remote server and using xmlrpclib for serialization
# Test of connecting to a remote server and using xmlrpclib for serialization
...
...
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