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
1e2ae4f0
Kaydet (Commit)
1e2ae4f0
authored
Eki 06, 2010
tarafından
Brian Quinlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixes 9903: test_concurrent_futures writes on stderr
üst
5ad8ed5f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
22 deletions
+33
-22
_base.py
Lib/concurrent/futures/_base.py
+2
-3
test_concurrent_futures.py
Lib/test/test_concurrent_futures.py
+31
-19
No files found.
Lib/concurrent/futures/_base.py
Dosyayı görüntüle @
1e2ae4f0
...
...
@@ -40,9 +40,8 @@ _STATE_TO_DESCRIPTION_MAP = {
# Logger for internal use by the futures package.
LOGGER
=
logging
.
getLogger
(
"concurrent.futures"
)
_handler
=
logging
.
StreamHandler
()
LOGGER
.
addHandler
(
_handler
)
del
_handler
STDERR_HANDLER
=
logging
.
StreamHandler
()
LOGGER
.
addHandler
(
STDERR_HANDLER
)
class
Error
(
Exception
):
"""Base class for all future-related exceptions."""
...
...
Lib/test/test_concurrent_futures.py
Dosyayı görüntüle @
1e2ae4f0
...
...
@@ -9,6 +9,8 @@ test.support.import_module('multiprocessing.synchronize')
# without thread support.
test
.
support
.
import_module
(
'threading'
)
import
io
import
logging
import
multiprocessing
import
sys
import
threading
...
...
@@ -21,7 +23,8 @@ if sys.platform.startswith('win'):
from
concurrent
import
futures
from
concurrent.futures._base
import
(
PENDING
,
RUNNING
,
CANCELLED
,
CANCELLED_AND_NOTIFIED
,
FINISHED
,
Future
,
wait
)
PENDING
,
RUNNING
,
CANCELLED
,
CANCELLED_AND_NOTIFIED
,
FINISHED
,
Future
,
LOGGER
,
STDERR_HANDLER
,
wait
)
import
concurrent.futures.process
def
create_future
(
state
=
PENDING
,
exception
=
None
,
result
=
None
):
...
...
@@ -617,24 +620,33 @@ class FutureTests(unittest.TestCase):
self
.
assertTrue
(
was_cancelled
)
def
test_done_callback_raises
(
self
):
raising_was_called
=
False
fn_was_called
=
False
def
raising_fn
(
callback_future
):
nonlocal
raising_was_called
raising_was_called
=
True
raise
Exception
(
'doh!'
)
def
fn
(
callback_future
):
nonlocal
fn_was_called
fn_was_called
=
True
f
=
Future
()
f
.
add_done_callback
(
raising_fn
)
f
.
add_done_callback
(
fn
)
f
.
set_result
(
5
)
self
.
assertTrue
(
raising_was_called
)
self
.
assertTrue
(
fn_was_called
)
LOGGER
.
removeHandler
(
STDERR_HANDLER
)
logging_stream
=
io
.
StringIO
()
handler
=
logging
.
StreamHandler
(
logging_stream
)
LOGGER
.
addHandler
(
handler
)
try
:
raising_was_called
=
False
fn_was_called
=
False
def
raising_fn
(
callback_future
):
nonlocal
raising_was_called
raising_was_called
=
True
raise
Exception
(
'doh!'
)
def
fn
(
callback_future
):
nonlocal
fn_was_called
fn_was_called
=
True
f
=
Future
()
f
.
add_done_callback
(
raising_fn
)
f
.
add_done_callback
(
fn
)
f
.
set_result
(
5
)
self
.
assertTrue
(
raising_was_called
)
self
.
assertTrue
(
fn_was_called
)
self
.
assertIn
(
'Exception: doh!'
,
logging_stream
.
getvalue
())
finally
:
LOGGER
.
removeHandler
(
handler
)
LOGGER
.
addHandler
(
STDERR_HANDLER
)
def
test_done_callback_already_successful
(
self
):
callback_result
=
None
...
...
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