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
e6994ff6
Kaydet (Commit)
e6994ff6
authored
Ock 26, 2014
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix issue #20367: concurrent.futures.as_completed() for duplicate arguments.
Patch by Glenn Langford.
üst
252fd0c2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
3 deletions
+16
-3
concurrent.futures.rst
Doc/library/concurrent.futures.rst
+2
-1
_base.py
Lib/concurrent/futures/_base.py
+4
-2
test_concurrent_futures.py
Lib/test/test_concurrent_futures.py
+7
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/concurrent.futures.rst
Dosyayı görüntüle @
e6994ff6
...
@@ -371,7 +371,8 @@ Module Functions
...
@@ -371,7 +371,8 @@ Module Functions
Returns an iterator over the :class:`Future` instances (possibly created by
Returns an iterator over the :class:`Future` instances (possibly created by
different :class:`Executor` instances) given by *fs* that yields futures as
different :class:`Executor` instances) given by *fs* that yields futures as
they complete (finished or were cancelled). Any futures that completed
they complete (finished or were cancelled). Any futures given by *fs* that
are duplicated will be returned once. Any futures that completed
before :func:`as_completed` is called will be yielded first. The returned
before :func:`as_completed` is called will be yielded first. The returned
iterator raises a :exc:`TimeoutError` if :meth:`~iterator.__next__` is
iterator raises a :exc:`TimeoutError` if :meth:`~iterator.__next__` is
called and the result isn't available after *timeout* seconds from the
called and the result isn't available after *timeout* seconds from the
...
...
Lib/concurrent/futures/_base.py
Dosyayı görüntüle @
e6994ff6
...
@@ -181,7 +181,8 @@ def as_completed(fs, timeout=None):
...
@@ -181,7 +181,8 @@ def as_completed(fs, timeout=None):
Returns:
Returns:
An iterator that yields the given Futures as they complete (finished or
An iterator that yields the given Futures as they complete (finished or
cancelled).
cancelled). If any given Futures are duplicated, they will be returned
once.
Raises:
Raises:
TimeoutError: If the entire result iterator could not be generated
TimeoutError: If the entire result iterator could not be generated
...
@@ -190,11 +191,12 @@ def as_completed(fs, timeout=None):
...
@@ -190,11 +191,12 @@ def as_completed(fs, timeout=None):
if
timeout
is
not
None
:
if
timeout
is
not
None
:
end_time
=
timeout
+
time
.
time
()
end_time
=
timeout
+
time
.
time
()
fs
=
set
(
fs
)
with
_AcquireFutures
(
fs
):
with
_AcquireFutures
(
fs
):
finished
=
set
(
finished
=
set
(
f
for
f
in
fs
f
for
f
in
fs
if
f
.
_state
in
[
CANCELLED_AND_NOTIFIED
,
FINISHED
])
if
f
.
_state
in
[
CANCELLED_AND_NOTIFIED
,
FINISHED
])
pending
=
set
(
fs
)
-
finished
pending
=
fs
-
finished
waiter
=
_create_and_install_waiters
(
fs
,
_AS_COMPLETED
)
waiter
=
_create_and_install_waiters
(
fs
,
_AS_COMPLETED
)
try
:
try
:
...
...
Lib/test/test_concurrent_futures.py
Dosyayı görüntüle @
e6994ff6
...
@@ -350,6 +350,13 @@ class AsCompletedTests:
...
@@ -350,6 +350,13 @@ class AsCompletedTests:
SUCCESSFUL_FUTURE
]),
SUCCESSFUL_FUTURE
]),
completed_futures
)
completed_futures
)
def
test_duplicate_futures
(
self
):
# Issue 20367. Duplicate futures should not raise exceptions or give
# duplicate responses.
future1
=
self
.
executor
.
submit
(
time
.
sleep
,
2
)
completed
=
[
f
for
f
in
futures
.
as_completed
([
future1
,
future1
])]
self
.
assertEqual
(
len
(
completed
),
1
)
class
ThreadPoolAsCompletedTests
(
ThreadPoolMixin
,
AsCompletedTests
,
unittest
.
TestCase
):
class
ThreadPoolAsCompletedTests
(
ThreadPoolMixin
,
AsCompletedTests
,
unittest
.
TestCase
):
pass
pass
...
...
Misc/NEWS
Dosyayı görüntüle @
e6994ff6
...
@@ -36,6 +36,9 @@ Core and Builtins
...
@@ -36,6 +36,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #20367: Fix behavior of concurrent.futures.as_completed() for
duplicate arguments. Patch by Glenn Langford.
- Issue #8260: The read(), readline() and readlines() methods of
- Issue #8260: The read(), readline() and readlines() methods of
codecs.StreamReader returned incomplete data when were called after
codecs.StreamReader returned incomplete data when were called after
readline() or read(size). Based on patch by Amaury Forgeot d'
Arc
.
readline() or read(size). Based on patch by Amaury Forgeot d'
Arc
.
...
...
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