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
5d236caf
Unverified
Kaydet (Commit)
5d236caf
authored
Kas 04, 2018
tarafından
Julien Palard
Kaydeden (comit)
GitHub
Kas 04, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-19675: Terminate processes if construction of a pool is failing. (GH-5614)
üst
b4db249c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
2 deletions
+54
-2
pool.py
Lib/multiprocessing/pool.py
+10
-2
_test_multiprocessing.py
Lib/test/_test_multiprocessing.py
+43
-0
2018-02-10-23-41-05.bpo-19675.-dj35-.rst
...S.d/next/Library/2018-02-10-23-41-05.bpo-19675.-dj35-.rst
+1
-0
No files found.
Lib/multiprocessing/pool.py
Dosyayı görüntüle @
5d236caf
...
...
@@ -174,7 +174,15 @@ class Pool(object):
self
.
_processes
=
processes
self
.
_pool
=
[]
self
.
_repopulate_pool
()
try
:
self
.
_repopulate_pool
()
except
Exception
:
for
p
in
self
.
_pool
:
if
p
.
exitcode
is
None
:
p
.
terminate
()
for
p
in
self
.
_pool
:
p
.
join
()
raise
self
.
_worker_handler
=
threading
.
Thread
(
target
=
Pool
.
_handle_workers
,
...
...
@@ -251,10 +259,10 @@ class Pool(object):
initargs
,
maxtasksperchild
,
wrap_exception
)
)
pool
.
append
(
w
)
w
.
name
=
w
.
name
.
replace
(
'Process'
,
'PoolWorker'
)
w
.
daemon
=
True
w
.
start
()
pool
.
append
(
w
)
util
.
debug
(
'added worker'
)
@staticmethod
...
...
Lib/test/_test_multiprocessing.py
Dosyayı görüntüle @
5d236caf
...
...
@@ -3,6 +3,7 @@
#
import
unittest
import
unittest.mock
import
queue
as
pyqueue
import
contextlib
import
time
...
...
@@ -4635,6 +4636,48 @@ class TestSimpleQueue(unittest.TestCase):
proc
.
join
()
class
TestPoolNotLeakOnFailure
(
unittest
.
TestCase
):
def
test_release_unused_processes
(
self
):
# Issue #19675: During pool creation, if we can't create a process,
# don't leak already created ones.
will_fail_in
=
3
forked_processes
=
[]
class
FailingForkProcess
:
def
__init__
(
self
,
**
kwargs
):
self
.
name
=
'Fake Process'
self
.
exitcode
=
None
self
.
state
=
None
forked_processes
.
append
(
self
)
def
start
(
self
):
nonlocal
will_fail_in
if
will_fail_in
<=
0
:
raise
OSError
(
"Manually induced OSError"
)
will_fail_in
-=
1
self
.
state
=
'started'
def
terminate
(
self
):
self
.
state
=
'stopping'
def
join
(
self
):
if
self
.
state
==
'stopping'
:
self
.
state
=
'stopped'
def
is_alive
(
self
):
return
self
.
state
==
'started'
or
self
.
state
==
'stopping'
with
self
.
assertRaisesRegex
(
OSError
,
'Manually induced OSError'
):
p
=
multiprocessing
.
pool
.
Pool
(
5
,
context
=
unittest
.
mock
.
MagicMock
(
Process
=
FailingForkProcess
))
p
.
close
()
p
.
join
()
self
.
assertFalse
(
any
(
process
.
is_alive
()
for
process
in
forked_processes
))
class
MiscTestCase
(
unittest
.
TestCase
):
def
test__all__
(
self
):
# Just make sure names in blacklist are excluded
...
...
Misc/NEWS.d/next/Library/2018-02-10-23-41-05.bpo-19675.-dj35-.rst
0 → 100644
Dosyayı görüntüle @
5d236caf
``multiprocessing.Pool`` no longer leaks processes if its initialization fails.
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