Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
3c7d4fb9
Commit
3c7d4fb9
authored
Jul 06, 2016
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unwrap a FileObjectThread before printing errors to it in the hub
Fixes #825.
parent
d3e7ad56
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
5 deletions
+34
-5
changelog.rst
changelog.rst
+3
-0
src/gevent/hub.py
src/gevent/hub.py
+7
-2
src/greentest/test__systemerror.py
src/greentest/test__systemerror.py
+24
-3
No files found.
changelog.rst
View file @
3c7d4fb9
...
...
@@ -114,6 +114,9 @@ Other Changes
- :class:`gevent.hub.signal` (aka :func:`gevent.signal`) now verifies
that its `handler` argument is callable, raising a :exc:`TypeError`
if it isn't. Reported in :issue:`818` by Peter Renström.
- If ``sys.stderr`` has been monkey-patched (not recommended),
exceptions that the hub reports aren't lost and can still be caught.
Reported in :issue:`825` by Jelle Smet.
1.1.1 (Apr 4, 2016)
===================
...
...
src/gevent/hub.py
View file @
3c7d4fb9
...
...
@@ -582,8 +582,13 @@ class Hub(RawGreenlet):
.. versionadded:: 1.2a1
"""
return
sys
.
stderr
# Unwrap any FileObjectThread we have thrown around sys.stderr
# (because it can't be used in the hub). Tricky because we are
# called in error situations when it's not safe to import.
stderr
=
sys
.
stderr
if
type
(
stderr
).
__name__
==
'FileObjectThread'
:
stderr
=
stderr
.
io
return
stderr
def
print_exception
(
self
,
context
,
type
,
value
,
tb
):
# Python 3 does not gracefully handle None value or tb in
...
...
src/greentest/test__systemerror.py
View file @
3c7d4fb9
...
...
@@ -12,9 +12,15 @@ MSG = 'should be re-raised and caught'
class
Test
(
greentest
.
TestCase
):
x
=
None
error_fatal
=
False
def
start
(
self
,
*
args
):
raise
NotImplementedError
def
setUp
(
self
):
self
.
x
=
None
def
test_sys_exit
(
self
):
self
.
start
(
sys
.
exit
,
MSG
)
...
...
@@ -35,6 +41,19 @@ class Test(greentest.TestCase):
else
:
raise
AssertionError
(
'must raise KeyboardInterrupt'
)
def
test_keyboard_interrupt_stderr_patched
(
self
):
from
gevent
import
monkey
monkey
.
patch_sys
(
stdin
=
False
,
stdout
=
False
,
stderr
=
True
)
try
:
try
:
self
.
start
(
raise_
,
KeyboardInterrupt
)
while
True
:
gevent
.
sleep
(
0.1
)
except
KeyboardInterrupt
:
pass
# expected
finally
:
sys
.
stderr
=
monkey
.
get_original
(
'sys'
,
'stderr'
)
def
test_system_error
(
self
):
self
.
start
(
raise_
,
SystemError
(
MSG
))
...
...
@@ -53,7 +72,8 @@ class Test(greentest.TestCase):
class
TestCallback
(
Test
):
def
tearDown
(
self
):
assert
not
self
.
x
.
pending
,
self
.
x
if
self
.
x
is
not
None
:
assert
not
self
.
x
.
pending
,
self
.
x
def
start
(
self
,
*
args
):
self
.
x
=
get_hub
().
loop
.
run_callback
(
*
args
)
...
...
@@ -63,7 +83,8 @@ class TestSpawn(Test):
def
tearDown
(
self
):
gevent
.
sleep
(
0.0001
)
assert
self
.
x
.
dead
,
self
.
x
if
self
.
x
is
not
None
:
assert
self
.
x
.
dead
,
self
.
x
def
start
(
self
,
*
args
):
self
.
x
=
gevent
.
spawn
(
*
args
)
...
...
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