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
78f55ffc
Kaydet (Commit)
78f55ffc
authored
Şub 10, 2016
tarafından
Charles-François Natali
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #23992: multiprocessing: make MapResult not fail-fast upon exception.
üst
eaf8ebc1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
8 deletions
+38
-8
pool.py
Lib/multiprocessing/pool.py
+12
-8
_test_multiprocessing.py
Lib/test/_test_multiprocessing.py
+24
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/multiprocessing/pool.py
Dosyayı görüntüle @
78f55ffc
...
...
@@ -638,22 +638,26 @@ class MapResult(ApplyResult):
self
.
_number_left
=
length
//
chunksize
+
bool
(
length
%
chunksize
)
def
_set
(
self
,
i
,
success_result
):
self
.
_number_left
-=
1
success
,
result
=
success_result
if
success
:
if
success
and
self
.
_success
:
self
.
_value
[
i
*
self
.
_chunksize
:(
i
+
1
)
*
self
.
_chunksize
]
=
result
self
.
_number_left
-=
1
if
self
.
_number_left
==
0
:
if
self
.
_callback
:
self
.
_callback
(
self
.
_value
)
del
self
.
_cache
[
self
.
_job
]
self
.
_event
.
set
()
else
:
self
.
_success
=
False
self
.
_value
=
result
if
self
.
_error_callback
:
self
.
_error_callback
(
self
.
_value
)
del
self
.
_cache
[
self
.
_job
]
self
.
_event
.
set
()
if
not
success
and
self
.
_success
:
# only store first exception
self
.
_success
=
False
self
.
_value
=
result
if
self
.
_number_left
==
0
:
# only consider the result ready once all jobs are done
if
self
.
_error_callback
:
self
.
_error_callback
(
self
.
_value
)
del
self
.
_cache
[
self
.
_job
]
self
.
_event
.
set
()
#
# Class whose instances are returned by `Pool.imap()`
...
...
Lib/test/_test_multiprocessing.py
Dosyayı görüntüle @
78f55ffc
...
...
@@ -1660,6 +1660,10 @@ def sqr(x, wait=0.0):
def
mul
(
x
,
y
):
return
x
*
y
def
raise_large_valuerror
(
wait
):
time
.
sleep
(
wait
)
raise
ValueError
(
"x"
*
1024
**
2
)
class
SayWhenError
(
ValueError
):
pass
def
exception_throwing_generator
(
total
,
when
):
...
...
@@ -1895,6 +1899,26 @@ class _TestPool(BaseTestCase):
with
self
.
assertRaises
(
RuntimeError
):
p
.
apply
(
self
.
_test_wrapped_exception
)
def
test_map_no_failfast
(
self
):
# Issue #23992: the fail-fast behaviour when an exception is raised
# during map() would make Pool.join() deadlock, because a worker
# process would fill the result queue (after the result handler thread
# terminated, hence not draining it anymore).
t_start
=
time
.
time
()
with
self
.
assertRaises
(
ValueError
):
with
self
.
Pool
(
2
)
as
p
:
try
:
p
.
map
(
raise_large_valuerror
,
[
0
,
1
])
finally
:
time
.
sleep
(
0.5
)
p
.
close
()
p
.
join
()
# check that we indeed waited for all jobs
self
.
assertGreater
(
time
.
time
()
-
t_start
,
0.9
)
def
raising
():
raise
KeyError
(
"key"
)
...
...
Misc/NEWS
Dosyayı görüntüle @
78f55ffc
...
...
@@ -179,6 +179,8 @@ Core and Builtins
Library
-------
-
Issue
#
23992
:
multiprocessing
:
make
MapResult
not
fail
-
fast
upon
exception
.
-
Issue
#
26243
:
Support
keyword
arguments
to
zlib
.
compress
().
Patch
by
Aviv
Palivoda
.
...
...
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