Merge fix-doc-makefile
This commit is contained in:
10
NEWS
10
NEWS
@@ -1,3 +1,13 @@
|
||||
0.9.7
|
||||
=====
|
||||
* GreenPipe is now a context manager (thanks, quad)
|
||||
* tpool.Proxy supports iterators properly
|
||||
* bug fixes in eventlet.green.os (thanks, Benoit)
|
||||
* much code cleanup from Tavis
|
||||
* a few more example apps
|
||||
* multitudinous improvements in Py3k compatibility from amajorek
|
||||
|
||||
|
||||
0.9.6
|
||||
=====
|
||||
* new EVENTLET_HUB environment variable allows you to select a hub without code
|
||||
|
@@ -41,7 +41,7 @@ easy_install eventlet
|
||||
|
||||
<p>Alternately, you can download the source tarball:
|
||||
<ul>
|
||||
<li><a href="http://pypi.python.org/packages/source/e/eventlet/eventlet-0.9.6.tar.gz">eventlet-0.9.6.tar.gz</a></li>
|
||||
<li><a href="http://pypi.python.org/packages/source/e/eventlet/eventlet-0.9.7.tar.gz">eventlet-0.9.7.tar.gz</a></li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
version_info = (0, 9, 7, 'dev1')
|
||||
version_info = (0, 9, 7)
|
||||
__version__ = ".".join(map(str, version_info))
|
||||
|
||||
try:
|
||||
|
@@ -34,9 +34,28 @@ except ImportError:
|
||||
|
||||
class Pool(object):
|
||||
"""
|
||||
Pool is a base class that implements resource limitation and construction.
|
||||
It is meant to be subclassed. When subclassing, define only
|
||||
the :meth:`create` method to implement the desired resource::
|
||||
Pool class implements resource limitation and construction.
|
||||
|
||||
There are two ways of using Pool: passing a `create` argument or
|
||||
subclassing. In either case you must provide a way to create
|
||||
the resource.
|
||||
|
||||
When using `create` argument, pass a function with no arguments::
|
||||
|
||||
http_pool = pools.Pool(create=httplib2.Http)
|
||||
|
||||
If you need to pass arguments, build a nullary function with either
|
||||
`lambda` expression::
|
||||
|
||||
http_pool = pools.Pool(create=lambda: httplib2.Http(timeout=90))
|
||||
|
||||
or `functools.partial`::
|
||||
|
||||
from functools import partial
|
||||
http_pool = pools.Pool(create=partial(httplib2.Http, timeout=90))
|
||||
|
||||
When subclassing, define only the :meth:`create` method
|
||||
to implement the desired resource::
|
||||
|
||||
class MyPool(pools.Pool):
|
||||
def create(self):
|
||||
@@ -67,7 +86,7 @@ class Pool(object):
|
||||
greenthread calling :meth:`get` to cooperatively yield until an item
|
||||
is :meth:`put` in.
|
||||
"""
|
||||
def __init__(self, min_size=0, max_size=4, order_as_stack=False):
|
||||
def __init__(self, min_size=0, max_size=4, order_as_stack=False, create=None):
|
||||
"""*order_as_stack* governs the ordering of the items in the free pool.
|
||||
If ``False`` (the default), the free items collection (of items that
|
||||
were created and were put back in the pool) acts as a round-robin,
|
||||
@@ -81,6 +100,9 @@ class Pool(object):
|
||||
self.current_size = 0
|
||||
self.channel = queue.LightQueue(0)
|
||||
self.free_items = collections.deque()
|
||||
if create is not None:
|
||||
self.create = create
|
||||
|
||||
for x in xrange(min_size):
|
||||
self.current_size += 1
|
||||
self.free_items.append(self.create())
|
||||
@@ -139,9 +161,11 @@ class Pool(object):
|
||||
return max(0, self.channel.getting() - self.channel.putting())
|
||||
|
||||
def create(self):
|
||||
"""Generate a new pool item. This method must be overridden in order
|
||||
for the pool to function. It accepts no arguments and returns a single
|
||||
instance of whatever thing the pool is supposed to contain.
|
||||
"""Generate a new pool item. In order for the pool to function,
|
||||
either this method must be overriden in a subclass or pool must be
|
||||
created with `create`=callable argument. It accepts no arguments
|
||||
and returns a single instance of whatever thing the pool is supposed
|
||||
to contain.
|
||||
|
||||
In general, :meth:`create` is called whenever the pool exceeds its
|
||||
previous high-water mark of concurrently-checked-out-items. In other
|
||||
|
Reference in New Issue
Block a user