Fixed a buncha things noticed during a code review.

This commit is contained in:
Ryan Williams 2010-01-18 17:19:23 -08:00
parent d2fa28ecdc
commit 1941d1e04d
4 changed files with 24 additions and 18 deletions

13
NEWS
View File

@ -1,21 +1,24 @@
0.9.3
=====
* tpooled gethostbyname is configurable via environment variable EVENTLET_TPOOL_GETHOSTBYNAME
* Removed greenio.Green_fileobject and refactored the code therein to be more efficient. Only call makefile() on sockets now; makeGreenFile() is deprecated. The main loss here is that of the readuntil method. Also, Green_fileobjects used to be auto-flushing; flush() must be called explicitly now.
* Improved documentation across the board.
* New debug module, used for enabling verbosity within Eventlet that can help debug applications or Eventlet itself.
* Bugfixes in tpool, green.select
* Bugfixes in tpool, green.select, patcher
* Moved primary api module to __init__ from api. It shouldn't be necessary to import eventlet.api anymore; import eventlet should do the same job.
* Proc module deprecated in favor of greenthread
* New module greenthread, with new class GreenThread.
* New GreenPool class that replaces pool.Pool.
* Deprecated coros.execute
* Deprecated coros.semaphore
* Deprecated Proc module (use greenthread module instead)
* Deprecated coros.execute (use eventlet.spawn instead)
* Deprecated coros.semaphore (use semaphore.Semaphore or semaphore.BoundedSemaphore instead)
* Moved coros.BoundedSemaphore to semaphore.BoundedSemaphore
* Moved coros.Semaphore to semaphore.Semaphore
* Moved coros.event to event.Event
* Deprecated api.tcp_listener, api.connect_tcp, api.ssl_listener
* Moved get_hub, use_hub, get_default_hub to eventlet.hubs
* Moved get_hub, use_hub, get_default_hub from eventlet.api to eventlet.hubs
* Renamed libevent hub to pyevent.
* Renamed coros.event to coros.Event
* Removed previously-deprecated features tcp_server, GreenSSL, erpc, and trap_errors.
* Removed saranwrap as an option for making db connections nonblocking in db_pool.

View File

@ -12,12 +12,14 @@ Eventlet on top of twisted provides:
* existing twisted code can be used without any changes
* existing blocking code can be used after trivial changes applied
NOTE: the maintainer of Eventlet's Twisted support no longer supports it; it still exists but may have had some breakage along the way. Please treat it as experimental, and if you'd like to maintain it, please do!
Eventlet features:
* utilities for spawning and controlling greenlet execution:
api.spawn, api.kill, proc module
* utilities for communicating between greenlets:
coros.Event, coros.Queue, proc module
event.Event, queue.Queue, semaphore.Semaphore
* standard Python modules that won't block the reactor:
eventlet.green package
* utilities specific to twisted hub:
@ -61,8 +63,8 @@ to call from anywhere:
1. Greenlet creation functions: api.spawn, proc.spawn,
twistedutil.deferToGreenThread and others based on api.spawn.
2. send(), send_exception(), poll(), ready() methods of coros.Event
and coros.Queue.
2. send(), send_exception(), poll(), ready() methods of event.Event
and queue.Queue.
3. wait(timeout=0) is identical to poll(). Currently only Proc.wait
supports timeout parameter.

View File

@ -9,7 +9,7 @@ from twisted.python import failure
from eventlet import proc
from eventlet.api import getcurrent
from eventlet.coros import Queue
from eventlet.event import Event
from eventlet.event import Event as BaseEvent
class ValueQueue(Queue):
@ -37,17 +37,17 @@ class ValueQueue(Queue):
return self.items and self.items[-1][1] is not None
class Event(Event):
class Event(BaseEvent):
def send(self, value, exc=None):
if self.ready():
self.reset()
return Event.send(self, value, exc)
return BaseEvent.send(self, value, exc)
def send_exception(self, *throw_args):
if self.ready():
self.reset()
return Event.send_exception(self, *throw_args)
return BaseEvent.send_exception(self, *throw_args)
class Producer2Event(object):

View File

@ -2,7 +2,8 @@
from tests import skipped, skip_unless
from unittest import TestCase, main
from eventlet import api, coros
from eventlet import api
from eventlet import event
from eventlet import db_pool
class DBTester(object):
@ -146,13 +147,13 @@ class TestDBConnectionPool(DBTester):
curs = conn.cursor()
results = []
SHORT_QUERY = "select * from test_table"
evt = coros.Event()
evt = event.Event()
def a_query():
self.assert_cursor_works(curs)
curs.execute(SHORT_QUERY)
results.append(2)
evt.send()
evt2 = coros.Event()
evt2 = event.Event()
api.spawn(a_query)
results.append(1)
self.assertEqual([1], results)
@ -223,13 +224,13 @@ class TestDBConnectionPool(DBTester):
LONG_QUERY = "select * from test_table"
SHORT_QUERY = "select * from test_table where row_id <= 20"
evt = coros.Event()
evt = event.Event()
def long_running_query():
self.assert_cursor_works(curs)
curs.execute(LONG_QUERY)
results.append(1)
evt.send()
evt2 = coros.Event()
evt2 = event.Event()
def short_running_query():
self.assert_cursor_works(curs2)
curs2.execute(SHORT_QUERY)
@ -373,7 +374,7 @@ class TestDBConnectionPool(DBTester):
conn = self.pool.get()
self.assertEquals(self.pool.free(), 0)
self.assertEquals(self.pool.waiting(), 0)
e = coros.Event()
e = event.Event()
def retrieve(pool, ev):
c = pool.get()
ev.send(c)