From 3346ca3438d9701ea44ce72a11d63df21851730f Mon Sep 17 00:00:00 2001
From: Ryan Williams
Date: Tue, 9 Mar 2010 17:53:34 -0800
Subject: [PATCH 1/4] 0.9.7 branding
---
NEWS | 9 +++++++++
doc/real_index.html | 2 +-
eventlet/__init__.py | 2 +-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 1f079ce..b2841b9 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
+0.9.7
+=====
+* GreenPipe is now a context manager
+* tpool.Proxy supports iterators properly
+* bug fixes in eventlet.green.os
+* 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
diff --git a/doc/real_index.html b/doc/real_index.html
index fad3ad0..62ca706 100644
--- a/doc/real_index.html
+++ b/doc/real_index.html
@@ -41,7 +41,7 @@ easy_install eventlet
Alternately, you can download the source tarball:
diff --git a/eventlet/__init__.py b/eventlet/__init__.py
index 51b7e61..a757d58 100644
--- a/eventlet/__init__.py
+++ b/eventlet/__init__.py
@@ -1,4 +1,4 @@
-version_info = (0, 9, 7, 'dev1')
+version_info = (0, 9, 7)
__version__ = ".".join(map(str, version_info))
try:
From c6b71436ba376aa0f6fb22fecd73919aac74a1a9 Mon Sep 17 00:00:00 2001
From: Ryan Williams
Date: Tue, 9 Mar 2010 18:02:12 -0800
Subject: [PATCH 3/4] Oops didn't read the log thoroughly, more NEWS
---
NEWS | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index b2841b9..61cab49 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,9 @@
0.9.7
=====
-* GreenPipe is now a context manager
+* GreenPipe is now a context manager (thanks, quad)
* tpool.Proxy supports iterators properly
-* bug fixes in eventlet.green.os
+* 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
From b334c3fa229ed9adb41ceb8f078808f6ca936c8c Mon Sep 17 00:00:00 2001
From: Sergey Shepelev
Date: Wed, 10 Mar 2010 09:02:46 +0300
Subject: [PATCH 4/4] added `create` argument to pools.Pool constructor
This argument takes a nullary function and assigns it to `self.create`,
so the function is used for creating new items in pool.
This is another method to create items in pool, sometimes simpler than
subclassing.
---
eventlet/pools.py | 38 +++++++++++++++++++++++++++++++-------
1 file changed, 31 insertions(+), 7 deletions(-)
diff --git a/eventlet/pools.py b/eventlet/pools.py
index 6f72285..39544bb 100644
--- a/eventlet/pools.py
+++ b/eventlet/pools.py
@@ -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