From 7e7181f768dc237b160298d63869c036c34dd2d4 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Thu, 28 Jan 2010 16:29:50 -0800 Subject: [PATCH] Doc updates, robustified multiple waiter queue tests. --- .hgignore | 1 + doc/real_index.html | 4 ++-- doc/testing.rst | 6 +++--- tests/queue_test.py | 23 +++++------------------ tests/test__coros_queue.py | 30 ++++++++---------------------- 5 files changed, 19 insertions(+), 45 deletions(-) diff --git a/.hgignore b/.hgignore index d732b71..1bd3dbf 100644 --- a/.hgignore +++ b/.hgignore @@ -9,6 +9,7 @@ build .DS_Store doc/_build annotated +cover nosetests*.xml .coverage *,cover \ No newline at end of file diff --git a/doc/real_index.html b/doc/real_index.html index 89ea689..699088f 100644 --- a/doc/real_index.html +++ b/doc/real_index.html @@ -20,7 +20,7 @@

Eventlet

-

Eventlet is a networking library written in Python. It achieves high scalability by using non-blocking io while at the same time retaining high programmer usability by using coroutines to make the non-blocking io operations appear blocking at the source code level.

+

Eventlet is a better way to write high-performance network applications. It achieves high scalability by using non-blocking io while at the same time retaining high programmer usability by using coroutines to make the non-blocking io operations appear blocking at the source code level.

API Documentation

@@ -43,7 +43,7 @@ easy_install eventlet

This is a relatively low-traffic list about using and developing eventlet. Look through the archives for some useful information and possible answers to questions.

-

There's an IRC channel dedicated to eventlet: #eventlet on freenode

. It's a pretty chill place to hang out! +

There's an IRC channel dedicated to eventlet: #eventlet on freenode. It's a pretty chill place to hang out!

Development

diff --git a/doc/testing.rst b/doc/testing.rst index 54c7986..d4c58b9 100644 --- a/doc/testing.rst +++ b/doc/testing.rst @@ -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,' + coverage html -d cover --omit='tempmod,,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) \ No newline at end of file +(``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.) \ No newline at end of file diff --git a/tests/queue_test.py b/tests/queue_test.py index 19ec9d3..fd6466b 100644 --- a/tests/queue_test.py +++ b/tests/queue_test.py @@ -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() diff --git a/tests/test__coros_queue.py b/tests/test__coros_queue.py index 447fa88..fee7998 100644 --- a/tests/test__coros_queue.py +++ b/tests/test__coros_queue.py @@ -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()