Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1e2ae4f0
Commit
1e2ae4f0
authored
Oct 06, 2010
by
Brian Quinlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes 9903: test_concurrent_futures writes on stderr
parent
5ad8ed5f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
22 deletions
+33
-22
Lib/concurrent/futures/_base.py
Lib/concurrent/futures/_base.py
+2
-3
Lib/test/test_concurrent_futures.py
Lib/test/test_concurrent_futures.py
+31
-19
No files found.
Lib/concurrent/futures/_base.py
View file @
1e2ae4f0
...
@@ -40,9 +40,8 @@ _STATE_TO_DESCRIPTION_MAP = {
...
@@ -40,9 +40,8 @@ _STATE_TO_DESCRIPTION_MAP = {
# Logger for internal use by the futures package.
# Logger for internal use by the futures package.
LOGGER
=
logging
.
getLogger
(
"concurrent.futures"
)
LOGGER
=
logging
.
getLogger
(
"concurrent.futures"
)
_handler
=
logging
.
StreamHandler
()
STDERR_HANDLER
=
logging
.
StreamHandler
()
LOGGER
.
addHandler
(
_handler
)
LOGGER
.
addHandler
(
STDERR_HANDLER
)
del
_handler
class
Error
(
Exception
):
class
Error
(
Exception
):
"""Base class for all future-related exceptions."""
"""Base class for all future-related exceptions."""
...
...
Lib/test/test_concurrent_futures.py
View file @
1e2ae4f0
...
@@ -9,6 +9,8 @@ test.support.import_module('multiprocessing.synchronize')
...
@@ -9,6 +9,8 @@ test.support.import_module('multiprocessing.synchronize')
# without thread support.
# without thread support.
test
.
support
.
import_module
(
'threading'
)
test
.
support
.
import_module
(
'threading'
)
import
io
import
logging
import
multiprocessing
import
multiprocessing
import
sys
import
sys
import
threading
import
threading
...
@@ -21,7 +23,8 @@ if sys.platform.startswith('win'):
...
@@ -21,7 +23,8 @@ if sys.platform.startswith('win'):
from
concurrent
import
futures
from
concurrent
import
futures
from
concurrent.futures._base
import
(
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
import
concurrent.futures.process
def
create_future
(
state
=
PENDING
,
exception
=
None
,
result
=
None
):
def
create_future
(
state
=
PENDING
,
exception
=
None
,
result
=
None
):
...
@@ -617,24 +620,33 @@ class FutureTests(unittest.TestCase):
...
@@ -617,24 +620,33 @@ class FutureTests(unittest.TestCase):
self
.
assertTrue
(
was_cancelled
)
self
.
assertTrue
(
was_cancelled
)
def
test_done_callback_raises
(
self
):
def
test_done_callback_raises
(
self
):
raising_was_called
=
False
LOGGER
.
removeHandler
(
STDERR_HANDLER
)
fn_was_called
=
False
logging_stream
=
io
.
StringIO
()
handler
=
logging
.
StreamHandler
(
logging_stream
)
def
raising_fn
(
callback_future
):
LOGGER
.
addHandler
(
handler
)
nonlocal
raising_was_called
try
:
raising_was_called
=
True
raising_was_called
=
False
raise
Exception
(
'doh!'
)
fn_was_called
=
False
def
fn
(
callback_future
):
def
raising_fn
(
callback_future
):
nonlocal
fn_was_called
nonlocal
raising_was_called
fn_was_called
=
True
raising_was_called
=
True
raise
Exception
(
'doh!'
)
f
=
Future
()
f
.
add_done_callback
(
raising_fn
)
def
fn
(
callback_future
):
f
.
add_done_callback
(
fn
)
nonlocal
fn_was_called
f
.
set_result
(
5
)
fn_was_called
=
True
self
.
assertTrue
(
raising_was_called
)
self
.
assertTrue
(
fn_was_called
)
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
):
def
test_done_callback_already_successful
(
self
):
callback_result
=
None
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