Commit f7566208 authored by Denis Bilenko's avatar Denis Bilenko

pool: rename GreenletSet to Group. The old name is available as an alias (will...

pool: rename GreenletSet to Group. The old name is available as an alias (will be removed in the future)
parent 9fcd1438
...@@ -6,11 +6,11 @@ from gevent.timeout import Timeout ...@@ -6,11 +6,11 @@ from gevent.timeout import Timeout
from gevent.event import Event from gevent.event import Event
from gevent.coros import Semaphore, DummySemaphore from gevent.coros import Semaphore, DummySemaphore
__all__ = ['GreenletSet', 'Pool'] __all__ = ['Group', 'Pool']
class GreenletSet(object): class Group(object):
"""Maintain a set of greenlets that are still running. """Maintain a group of greenlets that are still running.
Links to each item and removes it upon notification. Links to each item and removes it upon notification.
""" """
...@@ -31,7 +31,7 @@ class GreenletSet(object): ...@@ -31,7 +31,7 @@ class GreenletSet(object):
try: try:
classname = self.__class__.__name__ classname = self.__class__.__name__
except AttributeError: except AttributeError:
classname = 'GreenletSet' # XXX check if 2.4 really uses this line classname = 'Group' # XXX check if 2.4 really uses this line
return '<%s at %s %s>' % (classname, hex(id(self)), self.greenlets) return '<%s at %s %s>' % (classname, hex(id(self)), self.greenlets)
def __len__(self): def __len__(self):
...@@ -190,12 +190,15 @@ class GreenletSet(object): ...@@ -190,12 +190,15 @@ class GreenletSet(object):
pass pass
class Pool(GreenletSet): GreenletSet = Group # the old name; will be deprecated in the future
class Pool(Group):
def __init__(self, size=None, greenlet_class=None): def __init__(self, size=None, greenlet_class=None):
if size is not None and size < 0: if size is not None and size < 0:
raise ValueError('Invalid size for pool (positive integer or None required): %r' % (size, )) raise ValueError('Invalid size for pool (positive integer or None required): %r' % (size, ))
GreenletSet.__init__(self) Group.__init__(self)
self.size = size self.size = size
if greenlet_class is not None: if greenlet_class is not None:
self.greenlet_class = greenlet_class self.greenlet_class = greenlet_class
...@@ -265,7 +268,7 @@ class Pool(GreenletSet): ...@@ -265,7 +268,7 @@ class Pool(GreenletSet):
return greenlet return greenlet
def discard(self, greenlet): def discard(self, greenlet):
GreenletSet.discard(self, greenlet) Group.discard(self, greenlet)
self._semaphore.release() self._semaphore.release()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment