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
20f0c8be
Commit
20f0c8be
authored
Aug 13, 2009
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event: make sure callback passed to rawlink() is always called in hub's greenlet
parent
c5057e28
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
18 deletions
+21
-18
gevent/event.py
gevent/event.py
+21
-18
No files found.
gevent/event.py
View file @
20f0c8be
...
...
@@ -10,6 +10,7 @@ class Event(object):
def
__init__
(
self
):
self
.
_links
=
set
()
self
.
_value
=
_NONE
self
.
_notifier
=
None
def
ready
(
self
):
return
self
.
_value
is
not
_NONE
...
...
@@ -20,12 +21,11 @@ class Event(object):
return
self
.
_value
def
rawlink
(
self
,
callback
):
if
self
.
_value
is
_NONE
:
self
.
_links
.
add
(
callback
)
else
:
# QQQ switch won't work as a callback!
# QQQ should I schedule the callback here too, like Greenlet.rawlink does?
callback
(
self
)
if
not
callable
(
callback
):
raise
TypeError
(
'Expected callable: %r'
%
(
callback
,
))
self
.
_links
.
add
(
callback
)
if
self
.
ready
()
and
self
.
_notifier
is
None
:
self
.
_notifier
=
core
.
active_event
(
self
.
_notify_links
)
def
unlink
(
self
,
callback
):
self
.
_links
.
discard
(
callback
)
...
...
@@ -38,22 +38,25 @@ class Event(object):
oldvalue
=
self
.
_value
self
.
_value
=
value
if
oldvalue
is
_NONE
:
if
self
.
_links
:
core
.
active_event
(
self
.
_notify_links
)
if
self
.
_links
and
self
.
_notifier
is
None
:
self
.
_notifier
=
core
.
active_event
(
self
.
_notify_links
)
def
_notify_links
(
self
):
assert
getcurrent
()
is
get_hub
()
while
self
.
_links
:
link
=
self
.
_links
.
pop
()
try
:
link
(
self
)
except
:
traceback
.
print_exc
()
try
:
assert
getcurrent
()
is
get_hub
()
while
self
.
_links
:
link
=
self
.
_links
.
pop
()
try
:
sys
.
stderr
.
write
(
'Failed to notify link %r of %r
\
n
\
n
'
%
(
link
,
self
)
)
link
(
self
)
except
:
pass
# even if g is left unscheduled, it will be deallocated because there are no more references to it
traceback
.
print_exc
()
try
:
sys
.
stderr
.
write
(
'Failed to notify link %r of %r
\
n
\
n
'
%
(
link
,
self
))
except
:
pass
# even if g is left unscheduled, it will be deallocated because there are no more references to it
finally
:
self
.
_notifier
=
None
def
get
(
self
,
block
=
True
,
timeout
=
None
):
if
self
.
_value
is
not
_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