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
a268865b
Commit
a268865b
authored
Feb 22, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop reading private _exc_info variable. Fixes tests on PyPy.
parent
9c8e01d8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
61 deletions
+75
-61
src/gevent/greenlet.pxd
src/gevent/greenlet.pxd
+2
-2
src/greentest/test__issue330.py
src/greentest/test__issue330.py
+72
-59
src/greentest/tests_that_dont_monkeypatch.txt
src/greentest/tests_that_dont_monkeypatch.txt
+1
-0
No files found.
src/gevent/greenlet.pxd
View file @
a268865b
...
...
@@ -36,11 +36,11 @@ cdef class Greenlet(greenlet):
cdef
public
dict
spawn_tree_locals
cdef
readonly
_Frame
spawning_stack
# A test case reads th
ese
, otherwise they would
# A test case reads th
is
, otherwise they would
# be private
cdef
readonly
tuple
_exc_info
cdef
readonly
list
_links
cdef
object
tuple
_exc_info
cdef
object
_notifier
cdef
object
_start_event
cdef
dict
_kwargs
...
...
src/greentest/test__issue330.py
View file @
a268865b
# A greenlet that's killed before it is ever started
# should never be switched to
import
gevent
import
greentest
switched_to
=
[
False
,
False
]
def
runner
(
i
):
switched_to
[
i
]
=
True
def
check
(
g
,
g2
):
gevent
.
joinall
((
g
,
g2
))
assert
switched_to
==
[
False
,
False
],
switched_to
# They both have a GreenletExit as their value
assert
isinstance
(
g
.
value
,
gevent
.
GreenletExit
)
assert
isinstance
(
g2
.
value
,
gevent
.
GreenletExit
)
# They both have no reported exc_info
assert
g
.
_exc_info
==
(
None
,
None
,
None
)
assert
g2
.
_exc_info
==
(
None
,
None
,
None
)
assert
g
.
_exc_info
is
not
type
(
g
).
_exc_info
assert
g2
.
_exc_info
is
not
type
(
g2
).
_exc_info
switched_to
[:]
=
[
False
,
False
]
g
=
gevent
.
spawn
(
runner
,
0
)
# create but do not switch to
g2
=
gevent
.
spawn
(
runner
,
1
)
# create but do not switch to
# Using gevent.kill
gevent
.
kill
(
g
)
gevent
.
kill
(
g2
)
check
(
g
,
g2
)
# killing directly
g
=
gevent
.
spawn
(
runner
,
0
)
g2
=
gevent
.
spawn
(
runner
,
1
)
g
.
kill
()
g2
.
kill
()
check
(
g
,
g2
)
# throwing
g
=
gevent
.
spawn
(
runner
,
0
)
g2
=
gevent
.
spawn
(
runner
,
1
)
g
.
throw
(
gevent
.
GreenletExit
)
g2
.
throw
(
gevent
.
GreenletExit
)
check
(
g
,
g2
)
# Killing with gevent.kill gets the right exception
class
MyException
(
Exception
):
pass
def
catcher
():
try
:
while
True
:
gevent
.
sleep
(
0
)
except
Exception
as
e
:
switched_to
[
0
]
=
e
g
=
gevent
.
spawn
(
catcher
)
g
.
start
()
gevent
.
sleep
()
gevent
.
kill
(
g
,
MyException
())
gevent
.
sleep
()
assert
isinstance
(
switched_to
[
0
],
MyException
),
switched_to
class
TestSwitch
(
greentest
.
TestCase
):
def
setUp
(
self
):
self
.
switched_to
=
[
False
,
False
]
self
.
caught
=
None
def
runner
(
self
,
i
):
self
.
switched_to
[
i
]
=
True
def
check
(
self
,
g
,
g2
):
gevent
.
joinall
((
g
,
g2
))
self
.
assertEqual
([
False
,
False
],
self
.
switched_to
)
# They both have a GreenletExit as their value
self
.
assertIsInstance
(
g
.
value
,
gevent
.
GreenletExit
)
self
.
assertIsInstance
(
g2
.
value
,
gevent
.
GreenletExit
)
# They both have no reported exc_info
self
.
assertIsNone
(
g
.
exc_info
)
self
.
assertIsNone
(
g2
.
exc_info
)
self
.
assertIsNone
(
g
.
exception
)
self
.
assertIsNone
(
g2
.
exception
)
def
test_gevent_kill
(
self
):
g
=
gevent
.
spawn
(
self
.
runner
,
0
)
# create but do not switch to
g2
=
gevent
.
spawn
(
self
.
runner
,
1
)
# create but do not switch to
# Using gevent.kill
gevent
.
kill
(
g
)
gevent
.
kill
(
g2
)
self
.
check
(
g
,
g2
)
def
test_greenlet_kill
(
self
):
# killing directly
g
=
gevent
.
spawn
(
self
.
runner
,
0
)
g2
=
gevent
.
spawn
(
self
.
runner
,
1
)
g
.
kill
()
g2
.
kill
()
self
.
check
(
g
,
g2
)
def
test_throw
(
self
):
# throwing
g
=
gevent
.
spawn
(
self
.
runner
,
0
)
g2
=
gevent
.
spawn
(
self
.
runner
,
1
)
g
.
throw
(
gevent
.
GreenletExit
)
g2
.
throw
(
gevent
.
GreenletExit
)
self
.
check
(
g
,
g2
)
def
catcher
(
self
):
try
:
while
True
:
gevent
.
sleep
(
0
)
except
MyException
as
e
:
self
.
caught
=
e
def
test_kill_exception
(
self
):
# Killing with gevent.kill gets the right exception
g
=
gevent
.
spawn
(
self
.
catcher
)
g
.
start
()
gevent
.
sleep
()
gevent
.
kill
(
g
,
MyException
())
gevent
.
sleep
()
self
.
assertIsInstance
(
self
.
caught
,
MyException
)
self
.
assertIsNone
(
g
.
exception
,
MyException
)
if
__name__
==
'__main__'
:
greentest
.
main
()
src/greentest/tests_that_dont_monkeypatch.txt
View file @
a268865b
...
...
@@ -13,3 +13,4 @@ test__socket_errors.py
test__socket_send_memoryview.py
test__socket_timeout.py
test__examples.py
test__issue330.py
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