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
8b34b53c
Kaydet (Commit)
8b34b53c
authored
Mar 31, 2012
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #14406: Fix a race condition when using `concurrent.futures.wait(return_when=ALL_COMPLETED)`.
Patch by Matt Joiner.
üst
6eeadf0a
f70401e8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
_base.py
Lib/concurrent/futures/_base.py
+5
-3
test_concurrent_futures.py
Lib/test/test_concurrent_futures.py
+17
-1
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/concurrent/futures/_base.py
Dosyayı görüntüle @
8b34b53c
...
...
@@ -111,12 +111,14 @@ class _AllCompletedWaiter(_Waiter):
def
__init__
(
self
,
num_pending_calls
,
stop_on_exception
):
self
.
num_pending_calls
=
num_pending_calls
self
.
stop_on_exception
=
stop_on_exception
self
.
lock
=
threading
.
Lock
()
super
()
.
__init__
()
def
_decrement_pending_calls
(
self
):
self
.
num_pending_calls
-=
1
if
not
self
.
num_pending_calls
:
self
.
event
.
set
()
with
self
.
lock
:
self
.
num_pending_calls
-=
1
if
not
self
.
num_pending_calls
:
self
.
event
.
set
()
def
add_result
(
self
,
future
):
super
()
.
add_result
(
future
)
...
...
Lib/test/test_concurrent_futures.py
Dosyayı görüntüle @
8b34b53c
...
...
@@ -183,7 +183,9 @@ class ProcessPoolShutdownTest(ProcessPoolMixin, ExecutorShutdownTest):
for
p
in
processes
.
values
():
p
.
join
()
class
WaitTests
(
unittest
.
TestCase
):
def
test_first_completed
(
self
):
future1
=
self
.
executor
.
submit
(
mul
,
21
,
2
)
future2
=
self
.
executor
.
submit
(
time
.
sleep
,
1.5
)
...
...
@@ -284,7 +286,21 @@ class WaitTests(unittest.TestCase):
class
ThreadPoolWaitTests
(
ThreadPoolMixin
,
WaitTests
):
pass
def
test_pending_calls_race
(
self
):
# Issue #14406: multi-threaded race condition when waiting on all
# futures.
event
=
threading
.
Event
()
def
future_func
():
event
.
wait
()
oldswitchinterval
=
sys
.
getswitchinterval
()
sys
.
setswitchinterval
(
1e-6
)
try
:
fs
=
{
self
.
executor
.
submit
(
future_func
)
for
i
in
range
(
100
)}
event
.
set
()
futures
.
wait
(
fs
,
return_when
=
futures
.
ALL_COMPLETED
)
finally
:
sys
.
setswitchinterval
(
oldswitchinterval
)
class
ProcessPoolWaitTests
(
ProcessPoolMixin
,
WaitTests
):
...
...
Misc/NEWS
Dosyayı görüntüle @
8b34b53c
...
...
@@ -37,6 +37,9 @@ Core and Builtins
Library
-------
-
Issue
#
14406
:
Fix
a
race
condition
when
using
``
concurrent
.
futures
.
wait
(
return_when
=
ALL_COMPLETED
)``.
Patch
by
Matt
Joiner
.
-
Issue
#
5136
:
deprecate
old
,
unused
functions
from
tkinter
.
-
Issue
#
14409
:
IDLE
now
properly
executes
commands
in
the
Shell
window
...
...
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