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
5e6c1bcf
Commit
5e6c1bcf
authored
Feb 22, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop accessing private _links variable.
parent
a268865b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
11 deletions
+23
-11
src/gevent/greenlet.pxd
src/gevent/greenlet.pxd
+3
-4
src/gevent/greenlet.py
src/gevent/greenlet.py
+11
-0
src/greentest/test__greenlet.py
src/greentest/test__greenlet.py
+8
-6
src/greentest/test__local.py
src/greentest/test__local.py
+1
-1
No files found.
src/gevent/greenlet.pxd
View file @
5e6c1bcf
...
...
@@ -36,15 +36,14 @@ cdef class Greenlet(greenlet):
cdef
public
dict
spawn_tree_locals
cdef
readonly
_Frame
spawning_stack
# A test case reads this, otherwise they would
# be private
cdef
readonly
list
_links
cdef
object
tuple
_exc_info
cdef
list
_links
cdef
tuple
_exc_info
cdef
object
_notifier
cdef
object
_start_event
cdef
dict
_kwargs
cpdef
bint
has_links
(
self
)
cdef
bint
__started_but_aborted
(
self
)
cdef
bint
__start_cancelled_by_kill
(
self
)
...
...
src/gevent/greenlet.py
View file @
5e6c1bcf
...
...
@@ -674,6 +674,9 @@ class Greenlet(greenlet):
# pylint: disable=method-hidden
return
def
has_links
(
self
):
return
len
(
self
.
_links
)
def
rawlink
(
self
,
callback
):
"""Register a callable to be executed when the greenlet finishes execution.
...
...
@@ -708,6 +711,14 @@ class Greenlet(greenlet):
except
ValueError
:
pass
def
unlink_all
(
self
):
"""
Remove all the callbacks.
.. versionadded:: 1.3a2
"""
del
self
.
_links
[:]
def
link_value
(
self
,
callback
,
SpawnedLink
=
SuccessSpawnedLink
):
"""
Like :meth:`link` but *callback* is only notified when the greenlet
...
...
src/greentest/test__greenlet.py
View file @
5e6c1bcf
...
...
@@ -96,14 +96,17 @@ class TestUnlink(greentest.TestCase):
def
_test_func
(
self
,
p
,
link
):
link
(
dummy_test_func
)
assert
len
(
p
.
_links
)
==
1
,
p
.
_links
self
.
assertEqual
(
1
,
p
.
has_links
())
p
.
unlink
(
dummy_test_func
)
assert
not
p
.
_links
,
p
.
_links
self
.
assertEqual
(
0
,
p
.
has_links
())
link
(
self
.
setUp
)
assert
len
(
p
.
_links
)
==
1
,
p
.
_links
self
.
assertEqual
(
1
,
p
.
has_links
())
p
.
unlink
(
self
.
setUp
)
assert
not
p
.
_links
,
p
.
_links
self
.
assertEqual
(
0
,
p
.
has_links
())
p
.
kill
()
def
test_func_link
(
self
):
...
...
@@ -170,8 +173,7 @@ class TestReturn_link(LinksTestCase):
p
=
None
def
cleanup
(
self
):
while
self
.
p
.
_links
:
self
.
p
.
_links
.
pop
()
self
.
p
.
unlink_all
()
self
.
p
=
None
def
test_return
(
self
):
...
...
src/greentest/test__local.py
View file @
5e6c1bcf
...
...
@@ -273,7 +273,7 @@ class GeventLocalTestCase(greentest.TestCase):
self
.
assertEqual
(
count
,
len
(
deleted_sentinels
))
# The links were removed as well.
self
.
assert
Equal
(
list
(
running_greenlet
.
_links
),
[]
)
self
.
assert
False
(
running_greenlet
.
has_links
()
)
running_greenlet
=
gevent
.
spawn
(
demonstrate_my_local
)
...
...
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