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
a09b8437
Commit
a09b8437
authored
May 17, 2010
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GreenletSet: reimplement join() using Event
parent
9acd1461
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
gevent/pool.py
gevent/pool.py
+12
-10
No files found.
gevent/pool.py
View file @
a09b8437
...
...
@@ -23,6 +23,7 @@ class GreenletSet(object):
greenlet
.
rawlink
(
self
.
discard
)
# each item we kill we place in dying, to avoid killing the same greenlet twice
self
.
dying
=
set
()
self
.
_empty_event
=
Event
()
def
__repr__
(
self
):
try
:
...
...
@@ -43,10 +44,13 @@ class GreenletSet(object):
def
add
(
self
,
greenlet
):
greenlet
.
rawlink
(
self
.
discard
)
self
.
greenlets
.
add
(
greenlet
)
self
.
_empty_event
.
clear
()
def
discard
(
self
,
greenlet
):
self
.
greenlets
.
discard
(
greenlet
)
self
.
dying
.
discard
(
greenlet
)
if
not
self
.
greenlets
:
self
.
_empty_event
.
set
()
def
start
(
self
,
greenlet
):
self
.
add
(
greenlet
)
...
...
@@ -78,16 +82,14 @@ class GreenletSet(object):
# self.add = RaiseException("This %s has been closed" % self.__class__.__name__)
def
join
(
self
,
timeout
=
None
,
raise_error
=
False
):
timeout
=
Timeout
.
start_new
(
timeout
)
try
:
try
:
while
self
.
greenlets
:
joinall
(
self
.
greenlets
,
raise_error
=
raise_error
)
except
Timeout
,
ex
:
if
ex
is
not
timeout
:
raise
finally
:
timeout
.
cancel
()
if
raise_error
:
greenlets
=
self
.
greenlets
.
copy
()
self
.
_empty_event
.
wait
(
timeout
=
timeout
)
for
greenlet
in
greenlets
:
if
not
greenlet
.
successful
():
raise
greenlet
.
exception
else
:
self
.
_empty_event
.
wait
(
timeout
=
timeout
)
def
kill
(
self
,
exception
=
GreenletExit
,
block
=
True
,
timeout
=
None
):
timer
=
Timeout
.
start_new
(
timeout
)
...
...
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