Renamed libevent hub to pyevent.

This commit is contained in:
Ryan Williams
2009-12-16 22:40:10 -08:00
parent f21f724640
commit c7d3432b29
8 changed files with 31 additions and 30 deletions

1
NEWS
View File

@@ -1,6 +1,7 @@
0.9.3
=====
* 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

@@ -66,7 +66,7 @@ If you wish to run tests against a particular Twisted reactor, use ``--reactor=R
* poll
* selects
* libevent (requires pyevent)
* pyevent (requires pyevent installed on your system)
Writing Tests
-------------

View File

@@ -320,10 +320,10 @@ def get_default_hub():
then poll, then select.
"""
# libevent hub disabled for now because it is not thread-safe
# pyevent hub disabled for now because it is not thread-safe
#try:
# import eventlet.hubs.libevent
# return eventlet.hubs.libevent
# import eventlet.hubs.pyevent
# return eventlet.hubs.pyevent
#except:
# pass

View File

@@ -71,12 +71,12 @@ def requires_twisted(func):
return skip_unless(requirement)(func)
def skip_with_libevent(func):
""" Decorator that skips a test if we're using the libevent hub."""
def using_libevent(_f):
def skip_with_pyevent(func):
""" Decorator that skips a test if we're using the pyevent hub."""
def using_pyevent(_f):
from eventlet.api import get_hub
return 'libevent' in type(get_hub()).__module__
return skip_if(using_libevent)(func)
return 'pyevent' in type(get_hub()).__module__
return skip_if(using_pyevent)(func)
def skip_on_windows(func):

View File

@@ -1,4 +1,4 @@
from tests import skipped, LimitedTestCase, skip_with_libevent, TestIsTakingTooLong
from tests import skipped, LimitedTestCase, skip_with_pyevent, TestIsTakingTooLong
from unittest import main
from eventlet import api, util, coros, proc, greenio
from eventlet.green.socket import GreenSSLObject
@@ -186,7 +186,7 @@ class TestGreenIo(LimitedTestCase):
for bytes in (1000, 10000, 100000, 1000000):
test_sendall_impl(bytes)
@skip_with_libevent
@skip_with_pyevent
def test_multiple_readers(self):
recvsize = 2 * min_buf_size()
sendsize = 10 * recvsize

View File

@@ -34,8 +34,8 @@ class TestTimer(TestCase):
#t = timer.Timer(0, lambda: (called.append(True), hub.abort()))
#t.schedule()
# let's have a timer somewhere in the future; make sure abort() still works
# (for libevent, its dispatcher() does not exit if there is something scheduled)
# XXX libevent handles this, other hubs do not
# (for pyevent, its dispatcher() does not exit if there is something scheduled)
# XXX pyevent handles this, other hubs do not
#api.get_hub().schedule_call_global(10000, lambda: (called.append(True), hub.abort()))
api.get_hub().schedule_call_global(0, lambda: (called.append(True), hub.abort()))
hub.default_sleep = lambda: 0.0

View File

@@ -17,7 +17,7 @@ import random
from sys import stdout
import time
import re
from tests import skipped, skip_with_libevent
from tests import skipped, skip_with_pyevent
from unittest import TestCase, main
from eventlet import coros, api, tpool
@@ -70,7 +70,7 @@ class TestTpool(TestCase):
tpool.QUIET = False
tpool.killall()
@skip_with_libevent
@skip_with_pyevent
def test_a_buncha_stuff(self):
pool = coros.CoroutinePool(max_size=10)
waiters = []
@@ -79,7 +79,7 @@ class TestTpool(TestCase):
for waiter in waiters:
waiter.wait()
@skip_with_libevent
@skip_with_pyevent
def test_wrap_tuple(self):
my_tuple = (1, 2)
prox = tpool.Proxy(my_tuple)
@@ -87,7 +87,7 @@ class TestTpool(TestCase):
self.assertEqual(prox[1], 2)
self.assertEqual(len(my_tuple), 2)
@skip_with_libevent
@skip_with_pyevent
def test_wrap_string(self):
my_object = "whatever"
prox = tpool.Proxy(my_object)
@@ -95,7 +95,7 @@ class TestTpool(TestCase):
self.assertEqual(len(my_object), len(prox))
self.assertEqual(my_object.join(['a', 'b']), prox.join(['a', 'b']))
@skip_with_libevent
@skip_with_pyevent
def test_wrap_uniterable(self):
# here we're treating the exception as just a normal class
prox = tpool.Proxy(FloatingPointError())
@@ -107,7 +107,7 @@ class TestTpool(TestCase):
self.assertRaises(IndexError, index)
self.assertRaises(TypeError, key)
@skip_with_libevent
@skip_with_pyevent
def test_wrap_dict(self):
my_object = {'a':1}
prox = tpool.Proxy(my_object)
@@ -117,7 +117,7 @@ class TestTpool(TestCase):
self.assertEqual(repr(my_object), repr(prox))
self.assertEqual(`my_object`, `prox`)
@skip_with_libevent
@skip_with_pyevent
def test_wrap_module_class(self):
prox = tpool.Proxy(re)
self.assertEqual(tpool.Proxy, type(prox))
@@ -125,7 +125,7 @@ class TestTpool(TestCase):
self.assertEqual(exp.flags, 0)
self.assert_(repr(prox.compile))
@skip_with_libevent
@skip_with_pyevent
def test_wrap_eq(self):
prox = tpool.Proxy(re)
exp1 = prox.compile('.')
@@ -134,7 +134,7 @@ class TestTpool(TestCase):
exp3 = prox.compile('/')
self.assert_(exp1 != exp3)
@skip_with_libevent
@skip_with_pyevent
def test_wrap_nonzero(self):
prox = tpool.Proxy(re)
exp1 = prox.compile('.')
@@ -142,7 +142,7 @@ class TestTpool(TestCase):
prox2 = tpool.Proxy([1, 2, 3])
self.assert_(bool(prox2))
@skip_with_libevent
@skip_with_pyevent
def test_multiple_wraps(self):
prox1 = tpool.Proxy(re)
prox2 = tpool.Proxy(re)
@@ -151,18 +151,18 @@ class TestTpool(TestCase):
del x2
x3 = prox2.compile('.')
@skip_with_libevent
@skip_with_pyevent
def test_wrap_getitem(self):
prox = tpool.Proxy([0,1,2])
self.assertEqual(prox[0], 0)
@skip_with_libevent
@skip_with_pyevent
def test_wrap_setitem(self):
prox = tpool.Proxy([0,1,2])
prox[1] = 2
self.assertEqual(prox[1], 2)
@skip_with_libevent
@skip_with_pyevent
def test_raising_exceptions(self):
prox = tpool.Proxy(re)
def nofunc():
@@ -172,7 +172,7 @@ class TestTpool(TestCase):
def assertLessThan(self, a, b):
self.assert_(a < b, "%s is not less than %s" % (a, b))
@skip_with_libevent
@skip_with_pyevent
def test_variable_and_keyword_arguments_with_function_calls(self):
import optparse
parser = tpool.Proxy(optparse.OptionParser())
@@ -180,7 +180,7 @@ class TestTpool(TestCase):
opts,args = parser.parse_args(["-nfoo"])
self.assertEqual(opts.n, 'foo')
@skip_with_libevent
@skip_with_pyevent
def test_contention(self):
from tests import tpool_test
prox = tpool.Proxy(tpool_test)
@@ -193,14 +193,14 @@ class TestTpool(TestCase):
for waiter in waiters:
waiter.wait()
@skip_with_libevent
@skip_with_pyevent
def test_timeout(self):
import time
api.exc_after(0.1, api.TimeoutError())
self.assertRaises(api.TimeoutError,
tpool.execute, time.sleep, 0.3)
@skip_with_libevent
@skip_with_pyevent
def test_killall(self):
tpool.killall()
tpool.setup()