Doc updates, robustified multiple waiter queue tests.

This commit is contained in:
Ryan Williams
2010-01-28 16:29:50 -08:00
parent ee9023c3a9
commit 7e7181f768
5 changed files with 19 additions and 45 deletions

View File

@@ -9,6 +9,7 @@ build
.DS_Store
doc/_build
annotated
cover
nosetests*.xml
.coverage
*,cover

View File

@@ -20,7 +20,7 @@
<div class="section" id="eventlet">
<h1>Eventlet</h1>
<p>Eventlet is a networking library written in Python. It achieves high scalability by using <a class="reference external" href="http://en.wikipedia.org/wiki/Asynchronous_I/O#Select.28.2Fpoll.29_loops">non-blocking io</a> while at the same time retaining high programmer usability by using <a class="reference external" href="http://en.wikipedia.org/wiki/Coroutine">coroutines</a> to make the non-blocking io operations appear blocking at the source code level.</p>
<p>Eventlet is a better way to write high-performance network applications. It achieves high scalability by using <a class="reference external" href="http://en.wikipedia.org/wiki/Asynchronous_I/O#Select.28.2Fpoll.29_loops">non-blocking io</a> while at the same time retaining high programmer usability by using <a class="reference external" href="http://en.wikipedia.org/wiki/Coroutine">coroutines</a> to make the non-blocking io operations appear blocking at the source code level.</p>
<h3><a href="doc/">API Documentation</a></h3>
@@ -43,7 +43,7 @@ easy_install eventlet
<p>This is a relatively low-traffic list about using and developing eventlet. Look through the <a href="https://lists.secondlife.com/pipermail/eventletdev/">archives</a> for some useful information and possible answers to questions.</p>
<p>There's an IRC channel dedicated to eventlet: <a href="irc://kubrick.freenode.net/#eventlet">#eventlet on freenode</a></p>. It's a pretty chill place to hang out!
<p>There's an IRC channel dedicated to eventlet: <a href="irc://kubrick.freenode.net/#eventlet">#eventlet on freenode</a>. It's a pretty chill place to hang out!</p>
<h3>Development</h3>

View File

@@ -91,10 +91,10 @@ Coverage.py is an awesome tool for evaluating how much code was exercised by uni
After running the tests to completion, this will emit a huge wodge of module names and line numbers. For some reason, the ``--cover-inclusive`` option breaks everything rather than serving its purpose of limiting the coverage to the local files, so don't use that.
The annotate option is quite useful because it generates annotated source files that are much easier to read than line-number soup. Here's a command that runs the annotation, dumping the annotated files into a directory called "annotated":
The html option is quite useful because it generates nicely-formatted HTML that are much easier to read than line-number soup. Here's a command that generates the annotation, dumping the html files into a directory called "cover":
.. code-block:: sh
coverage annotate -d annotated --omit='tempmod,<console>'
coverage html -d cover --omit='tempmod,<console>,tests'
(``tempmod`` and ``console`` are omitted because they gets thrown away at the completion of their unit tests and coverage.py isn't smart enough to detect this)
(``tempmod`` and ``console`` are omitted because they gets thrown away at the completion of their unit tests and coverage.py isn't smart enough to detect this.)

View File

@@ -72,33 +72,20 @@ class TestQueue(LimitedTestCase):
# tests that multiple waiters get their results back
q = eventlet.Queue()
def waiter(q):
return q.get()
sendings = ['1', '2', '3', '4']
gts = [eventlet.spawn(waiter, q)
gts = [eventlet.spawn(q.get)
for x in sendings]
eventlet.sleep(0.01) # get 'em all waiting
results = set()
def collect_pending_results():
for i, gt in enumerate(gts):
timer = eventlet.exc_after(0.001, eventlet.TimeoutError)
try:
x = gt.wait()
results.add(x)
timer.cancel()
except eventlet.TimeoutError:
pass # no pending result at that event
return len(results)
q.put(sendings[0])
self.assertEquals(collect_pending_results(), 1)
q.put(sendings[1])
self.assertEquals(collect_pending_results(), 2)
q.put(sendings[2])
q.put(sendings[3])
self.assertEquals(collect_pending_results(), 4)
results = set()
for i, gt in enumerate(gts):
results.add(gt.wait())
self.assertEquals(results, set(sendings))
def test_waiters_that_cancel(self):
q = eventlet.Queue()

View File

@@ -73,34 +73,20 @@ class TestQueue(LimitedTestCase):
# tests that multiple waiters get their results back
q = coros.queue()
def waiter(q, evt):
evt.send(q.wait())
sendings = ['1', '2', '3', '4']
evts = [coros.Event() for x in sendings]
for i, x in enumerate(sendings):
api.spawn(waiter, q, evts[i])
gts = [eventlet.spawn(q.wait)
for x in sendings]
eventlet.sleep(0.01) # get 'em all waiting
api.sleep(0.01) # get 'em all waiting
results = set()
def collect_pending_results():
for i, e in enumerate(evts):
timer = api.exc_after(0.001, api.TimeoutError)
try:
x = e.wait()
results.add(x)
timer.cancel()
except api.TimeoutError:
pass # no pending result at that event
return len(results)
q.send(sendings[0])
self.assertEquals(collect_pending_results(), 1)
q.send(sendings[1])
self.assertEquals(collect_pending_results(), 2)
q.send(sendings[2])
q.send(sendings[3])
self.assertEquals(collect_pending_results(), 4)
results = set()
for i, gt in enumerate(gts):
results.add(gt.wait())
self.assertEquals(results, set(sendings))
def test_waiters_that_cancel(self):
q = coros.queue()