Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Reorganize the namespaces

Get rid of some tests for old code
  • Loading branch information...
commit c264828ac6dd57a3b8f7e257899cce41e456ccd6 1 parent 5cf82a0
Alvaro authored November 19, 2012

Showing 42 changed files with 528 additions and 1,496 deletions. Show diff stats Hide diff stats

  1. 46  evy/__init__.py
  2. 34  evy/compat/__init__.py
  3. 49  evy/compat/eventlet.py
  4. 37  evy/green/OpenSSL/__init__.py
  5. 38  evy/green/__init__.py
  6. 37  evy/greenpool.py
  7. 5  evy/hubs/__init__.py
  8. 23  evy/pool.py
  9. 5  evy/support/__init__.py
  10. 3  evy/uv/__init__.py
  11. 2  evy/uv/watchers.py
  12. 25  tests/__init__.py
  13. 2  tests/stdlib/all_monkey.py
  14. 4  tests/test_backdoor.py
  15. 65  tests/test_convenience.py
  16. 26  tests/test_db_pool.py
  17. 6  tests/test_debug.py
  18. 140  tests/test_env.py
  19. 20  tests/test_event.py
  20. 8  tests/test_fork.py
  21. 70  tests/test_green_pool.py
  22. 32  tests/test_green_socket.py
  23. 7  tests/test_greenness.py
  24. 54  tests/test_hub.py
  25. 10  tests/test_mysqldb.py
  26. 12  tests/test_patcher.py
  27. 2  tests/test_patcher_psycopg.py
  28. 60  tests/test_pool.py
  29. 25  tests/test_pools.py
  30. 437  tests/test_proc.py
  31. 139  tests/test_processes.py
  32. 60  tests/test_queue.py
  33. 441  tests/test_saranwrap.py
  34. 10  tests/test_semaphore.py
  35. 2  tests/test_ssl.py
  36. 4  tests/test_thread.py
  37. 12  tests/test_timeout_with_statement.py
  38. 2  tests/test_timer.py
  39. 26  tests/test_tpool.py
  40. 15  tests/test_websocket.py
  41. 22  tests/test_wsgi.py
  42. 7  tests/test_zmq.py
46  evy/__init__.py
@@ -27,49 +27,9 @@
27 27
 # THE SOFTWARE.
28 28
 #
29 29
 
30  
-version_info = (0, 0, 1, "dev")
31  
-__version__ = ".".join(map(str, version_info))
32  
-
33  
-try:
34  
-    from evy import greenthread
35  
-    from evy import greenpool
36  
-    from evy import queue
37  
-    from evy import timeout
38  
-    from evy import patcher
39  
-    from evy import convenience
40  
-    import greenlet
41  
-
42  
-    sleep = greenthread.sleep
43  
-    spawn = greenthread.spawn
44  
-    spawn_n = greenthread.spawn_n
45  
-    spawn_after = greenthread.spawn_after
46  
-    kill = greenthread.kill
47  
-
48  
-    Timeout = TimeoutError = timeout.Timeout
49  
-    with_timeout = timeout.with_timeout
50  
-
51  
-    GreenPool = greenpool.GreenPool
52  
-    GreenPile = greenpool.GreenPile
53 30
 
54  
-    Queue = queue.Queue
  31
+__import__('pkg_resources').declare_namespace(__name__)
55 32
 
56  
-    import_patched = patcher.import_patched
57  
-    monkey_patch = patcher.monkey_patch
58 33
 
59  
-    connect = convenience.connect
60  
-    listen = convenience.listen
61  
-    serve = convenience.serve
62  
-    StopServe = convenience.StopServe
63  
-    wrap_ssl = convenience.wrap_ssl
64  
-
65  
-    getcurrent = greenlet.greenlet.getcurrent
66  
-
67  
-except ImportError, e:
68  
-    # This is to make Debian packaging easier, it ignores import
69  
-    # errors of greenlet so that the packager can still at least
70  
-    # access the version.  Also this makes easy_install a little quieter
71  
-    if 'greenlet' not in str(e):
72  
-        # any other exception should be printed
73  
-        import traceback
74  
-
75  
-        traceback.print_exc()
  34
+version_info = (0, 0, 1, "dev")
  35
+__version__ = ".".join(map(str, version_info))
34  evy/compat/__init__.py
... ...
@@ -1 +1,33 @@
1  
-__author__ = 'alvaro'
  1
+#
  2
+# Evy - a concurrent networking library for Python
  3
+#
  4
+# Unless otherwise noted, the files in Evy are under the following MIT license:
  5
+#
  6
+# Copyright (c) 2012, Alvaro Saurin
  7
+# Copyright (c) 2008-2010, Eventlet Contributors (see AUTHORS)
  8
+# Copyright (c) 2007-2010, Linden Research, Inc.
  9
+# Copyright (c) 2005-2006, Bob Ippolito
  10
+#
  11
+# Permission is hereby granted, free of charge, to any person obtaining a copy
  12
+# of this software and associated documentation files (the "Software"), to deal
  13
+# in the Software without restriction, including without limitation the rights
  14
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15
+# copies of the Software, and to permit persons to whom the Software is
  16
+# furnished to do so, subject to the following conditions:
  17
+#
  18
+# The above copyright notice and this permission notice shall be included in
  19
+# all copies or substantial portions of the Software.
  20
+#
  21
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  27
+# THE SOFTWARE.
  28
+#
  29
+
  30
+
  31
+__import__('pkg_resources').declare_namespace(__name__)
  32
+
  33
+
49  evy/compat/eventlet.py
@@ -23,3 +23,52 @@
23 23
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 24
 # THE SOFTWARE.
25 25
 #
  26
+
  27
+
  28
+
  29
+
  30
+try:
  31
+    from evy import version_info, __version__
  32
+
  33
+    from evy import greenthread
  34
+    from evy import greenpool
  35
+    from evy import queue
  36
+    from evy import timeout
  37
+    from evy import patcher
  38
+    from evy import convenience
  39
+    import greenlet
  40
+
  41
+    sleep = greenthread.sleep
  42
+    spawn = greenthread.spawn
  43
+    spawn_n = greenthread.spawn_n
  44
+    spawn_after = greenthread.spawn_after
  45
+    kill = greenthread.kill
  46
+
  47
+    Timeout = TimeoutError = timeout.Timeout
  48
+    with_timeout = timeout.with_timeout
  49
+
  50
+    GreenPool = greenpool.GreenPool
  51
+    GreenPile = greenpool.GreenPile
  52
+
  53
+    Queue = queue.Queue
  54
+
  55
+    import_patched = patcher.import_patched
  56
+    monkey_patch = patcher.monkey_patch
  57
+
  58
+    connect = convenience.connect
  59
+    listen = convenience.listen
  60
+    serve = convenience.serve
  61
+    StopServe = convenience.StopServe
  62
+    wrap_ssl = convenience.wrap_ssl
  63
+
  64
+    getcurrent = greenlet.greenlet.getcurrent
  65
+
  66
+except ImportError, e:
  67
+    # This is to make Debian packaging easier, it ignores import
  68
+    # errors of greenlet so that the packager can still at least
  69
+    # access the version.  Also this makes easy_install a little quieter
  70
+    if 'greenlet' not in str(e):
  71
+        # any other exception should be printed
  72
+        import traceback
  73
+
  74
+        traceback.print_exc()
37  evy/green/OpenSSL/__init__.py
... ...
@@ -1,2 +1,37 @@
  1
+#
  2
+# Evy - a concurrent networking library for Python
  3
+#
  4
+# Unless otherwise noted, the files in Evy are under the following MIT license:
  5
+#
  6
+# Copyright (c) 2012, Alvaro Saurin
  7
+# Copyright (c) 2008-2010, Eventlet Contributors (see AUTHORS)
  8
+# Copyright (c) 2007-2010, Linden Research, Inc.
  9
+# Copyright (c) 2005-2006, Bob Ippolito
  10
+#
  11
+# Permission is hereby granted, free of charge, to any person obtaining a copy
  12
+# of this software and associated documentation files (the "Software"), to deal
  13
+# in the Software without restriction, including without limitation the rights
  14
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15
+# copies of the Software, and to permit persons to whom the Software is
  16
+# furnished to do so, subject to the following conditions:
  17
+#
  18
+# The above copyright notice and this permission notice shall be included in
  19
+# all copies or substantial portions of the Software.
  20
+#
  21
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  27
+# THE SOFTWARE.
  28
+#
  29
+
  30
+
  31
+
  32
+
  33
+__import__('pkg_resources').declare_namespace(__name__)
  34
+
1 35
 import rand, crypto, SSL, tsafe
2  
-from version import __version__
  36
+from version import __version__
  37
+
38  evy/green/__init__.py
... ...
@@ -1 +1,37 @@
1  
-# this package contains modules from the standard library converted to use evy
  1
+#
  2
+# Evy - a concurrent networking library for Python
  3
+#
  4
+# Unless otherwise noted, the files in Evy are under the following MIT license:
  5
+#
  6
+# Copyright (c) 2012, Alvaro Saurin
  7
+# Copyright (c) 2008-2010, Eventlet Contributors (see AUTHORS)
  8
+# Copyright (c) 2007-2010, Linden Research, Inc.
  9
+# Copyright (c) 2005-2006, Bob Ippolito
  10
+#
  11
+# Permission is hereby granted, free of charge, to any person obtaining a copy
  12
+# of this software and associated documentation files (the "Software"), to deal
  13
+# in the Software without restriction, including without limitation the rights
  14
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15
+# copies of the Software, and to permit persons to whom the Software is
  16
+# furnished to do so, subject to the following conditions:
  17
+#
  18
+# The above copyright notice and this permission notice shall be included in
  19
+# all copies or substantial portions of the Software.
  20
+#
  21
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  27
+# THE SOFTWARE.
  28
+#
  29
+
  30
+
  31
+
  32
+"""
  33
+This package contains modules from the standard library converted to use Evy
  34
+"""
  35
+
  36
+
  37
+__import__('pkg_resources').declare_namespace(__name__)
37  evy/greenpool.py
@@ -40,8 +40,12 @@
40 40
 
41 41
 DEBUG = True
42 42
 
  43
+
  44
+
  45
+
43 46
 class GreenPool(object):
44  
-    """The GreenPool class is a pool of green threads.
  47
+    """
  48
+    The GreenPool class is a pool of green threads.
45 49
     """
46 50
 
47 51
     def __init__ (self, size = 1000):
@@ -69,14 +73,16 @@ def running (self):
69 73
         return len(self.coroutines_running)
70 74
 
71 75
     def free (self):
72  
-        """ Returns the number of greenthreads available for use.
  76
+        """
  77
+        Returns the number of greenthreads available for use.
73 78
 
74 79
         If zero or less, the next call to :meth:`spawn` or :meth:`spawn_n` will
75 80
         block the calling greenthread until a slot becomes available."""
76 81
         return self.sem.counter
77 82
 
78 83
     def spawn (self, function, *args, **kwargs):
79  
-        """Run the *function* with its arguments in its own green thread.
  84
+        """
  85
+        Run the *function* with its arguments in its own green thread.
80 86
         Returns the :class:`GreenThread <evy.greenthread.GreenThread>`
81 87
         object that is running the function, which can be used to retrieve the
82 88
         results.
@@ -201,7 +207,8 @@ def return_stop_iteration ():
201 207
 
202 208
 
203 209
 class GreenPile(object):
204  
-    """GreenPile is an abstraction representing a bunch of I/O-related tasks.
  210
+    """
  211
+    GreenPile is an abstraction representing a bunch of I/O-related tasks.
205 212
 
206 213
     Construct a GreenPile with an existing GreenPool object.  The GreenPile will
207 214
     then use that pool's concurrency as it processes its jobs.  There can be
@@ -226,8 +233,10 @@ def __init__ (self, size_or_pool = 1000):
226 233
         self.counter = 0
227 234
 
228 235
     def spawn (self, func, *args, **kw):
229  
-        """Runs *func* in its own green thread, with the result available by
230  
-        iterating over the GreenPile object."""
  236
+        """
  237
+        Runs *func* in its own green thread, with the result available by
  238
+        iterating over the GreenPile object.
  239
+        """
231 240
         self.used = True
232 241
         self.counter += 1
233 242
         try:
@@ -241,8 +250,10 @@ def __iter__ (self):
241 250
         return self
242 251
 
243 252
     def next (self):
244  
-        """Wait for the next result, suspending the current greenthread until it
245  
-        is available.  Raises StopIteration when there are no more results."""
  253
+        """
  254
+        Wait for the next result, suspending the current greenthread until it
  255
+        is available.  Raises StopIteration when there are no more results.
  256
+        """
246 257
         if self.counter == 0 and self.used:
247 258
             raise StopIteration()
248 259
         try:
@@ -250,10 +261,14 @@ def next (self):
250 261
         finally:
251 262
             self.counter -= 1
252 263
 
253  
-# this is identical to GreenPile but it blocks on spawn if the results
254  
-# aren't consumed, and it doesn't generate its own StopIteration exception,
255  
-# instead relying on the spawning process to send one in when it's done
  264
+
256 265
 class GreenMap(GreenPile):
  266
+    """
  267
+    A GreenMap is identical to GreenPile but it blocks on spawn if the results
  268
+    aren't consumed, and it doesn't generate its own StopIteration exception,
  269
+    instead relying on the spawning process to send one in when it's done
  270
+    """
  271
+
257 272
     def __init__ (self, size_or_pool):
258 273
         super(GreenMap, self).__init__(size_or_pool)
259 274
         self.waiters = queue.LightQueue(maxsize = self.pool.size)
5  evy/hubs/__init__.py
@@ -27,6 +27,11 @@
27 27
 # THE SOFTWARE.
28 28
 #
29 29
 
  30
+
  31
+__import__('pkg_resources').declare_namespace(__name__)
  32
+
  33
+
  34
+
30 35
 from evy.support import greenlets as greenlet
31 36
 from evy import patcher
32 37
 
23  evy/pool.py
@@ -27,7 +27,12 @@
27 27
 # THE SOFTWARE.
28 28
 #
29 29
 
30  
-from evy import coros
  30
+import greenlet
  31
+from greenlet.greenlet import getcurrent
  32
+
  33
+from evy.greenpool import GreenPool
  34
+from evy.greenthread import spawn
  35
+from evy.queue import Queue
31 36
 from evy.semaphore import Semaphore
32 37
 
33 38
 import warnings
@@ -42,9 +47,9 @@ def __init__ (self, min_size = 0, max_size = 4, track_events = False):
42 47
             raise ValueError('min_size cannot be bigger than max_size')
43 48
         self.max_size = max_size
44 49
         self.sem = Semaphore(max_size)
45  
-        self.procs = proc.RunningProcSet()
  50
+        self.procs = GreenPool()
46 51
         if track_events:
47  
-            self.results = coros.queue()
  52
+            self.results = Queue()
48 53
         else:
49 54
             self.results = None
50 55
 
@@ -63,7 +68,7 @@ def resize (self, new_max_size):
63 68
     @property
64 69
     def current_size (self):
65 70
         """ The number of coroutines that are currently executing jobs. """
66  
-        return len(self.procs)
  71
+        return self.procs.running()
67 72
 
68 73
     def free (self):
69 74
         """ Returns the number of coroutines that are available for doing
@@ -84,8 +89,8 @@ def execute (self, func, *args, **kwargs):
84 89
         """
85 90
         # if reentering an empty pool, don't try to wait on a coroutine freeing
86 91
         # itself -- instead, just execute in the current coroutine
87  
-        if self.sem.locked() and api.getcurrent() in self.procs:
88  
-            p = proc.spawn(func, *args, **kwargs)
  92
+        if self.sem.locked() and getcurrent() in self.procs:
  93
+            p = spawn(func, *args, **kwargs)
89 94
             try:
90 95
                 p.wait()
91 96
             except:
@@ -158,7 +163,6 @@ def process_all (self, function, iterable):
158 163
         coroutines, newly-launched plus any previously-submitted :meth:`execute()`
159 164
         or :meth:`execute_async` calls, have completed.
160 165
 
161  
-        >>> from evy import coros
162 166
         >>> pool = coros.CoroutinePool()
163 167
         >>> def saw(x): print "I saw %s!" % x
164 168
         ...
@@ -215,9 +219,8 @@ def generate_results (self, function, iterable, qsize = None):
215 219
         above is when the *iterable*, which may itself be a generator, produces
216 220
         millions of items.)
217 221
 
218  
-        >>> from evy import coros
219 222
         >>> import string
220  
-        >>> pool = coros.CoroutinePool(max_size=5)
  223
+        >>> pool = CoroutinePool(max_size=5)
221 224
         >>> pausers = [coros.Event() for x in xrange(2)]
222 225
         >>> def longtask(evt, desc):
223 226
         ...     print "%s woke up with %s" % (desc, evt.wait())
@@ -291,7 +294,7 @@ def generate_results (self, function, iterable, qsize = None):
291 294
         # coroutine calls send(result). We slyly pass a queue rather than an
292 295
         # event -- the same queue instance for all coroutines. This is why our
293 296
         # queue interface intentionally resembles the event interface.
294  
-        q = coros.queue(max_size = qsize)
  297
+        q = Queue(max_size = qsize)
295 298
         # How many results have we yielded so far?
296 299
         finished = 0
297 300
         # This first loop is only until we've launched all the coroutines. Its
5  evy/support/__init__.py
@@ -27,6 +27,11 @@
27 27
 # THE SOFTWARE.
28 28
 #
29 29
 
  30
+
  31
+__import__('pkg_resources').declare_namespace(__name__)
  32
+
  33
+
  34
+
30 35
 import sys
31 36
 
32 37
 def get_errno (exc):
3  evy/uv/__init__.py
@@ -28,5 +28,8 @@
28 28
 #
29 29
 
30 30
 
  31
+__import__('pkg_resources').declare_namespace(__name__)
  32
+
  33
+
31 34
 from interface import libuv, ffi, get_version
32 35
 from watchers import Watcher, Poll, Timer, Async, Callback, Idle, Prepare, Signal
2  evy/uv/watchers.py
@@ -327,7 +327,7 @@ def start(self, callback, *args, **kwargs):
327 327
 
328 328
         if update: libuv.uv_update_time(self.hub._uv_ptr)
329 329
 
330  
-        libuv.uv_timer_start(self._uv_handle, self._cb, self._after, self._repeat)
  330
+        libuv.uv_timer_start(self._uv_handle, self._cb, int(self._after), int(self._repeat))
331 331
 
332 332
 
333 333
 
25  tests/__init__.py
... ...
@@ -1,4 +1,6 @@
1 1
 # package is named tests, not test, so it won't be confused with test in stdlib
  2
+
  3
+
2 4
 import sys
3 5
 import os
4 6
 import errno
@@ -7,6 +9,8 @@
7 9
 
8 10
 from evy import debug, hubs
9 11
 
  12
+from evy.timeout import Timeout
  13
+
10 14
 # convenience for importers
11 15
 main = unittest.main
12 16
 
@@ -130,26 +134,25 @@ class TestIsTakingTooLong(Exception):
130 134
 
131 135
 
132 136
 class LimitedTestCase(unittest.TestCase):
133  
-    """ Unittest subclass that adds a timeout to all tests.  Subclasses must
  137
+    """
  138
+    Unittest subclass that adds a timeout to all tests.  Subclasses must
134 139
     be sure to call the LimitedTestCase setUp and tearDown methods.  The default 
135 140
     timeout is 1 second, change it by setting self.TEST_TIMEOUT to the desired
136  
-    quantity."""
  141
+    quantity.
  142
+    """
137 143
 
138 144
     TEST_TIMEOUT = 1
139 145
 
140 146
     def setUp (self):
141  
-        import evy
142  
-
143  
-        self.timer = evy.Timeout(self.TEST_TIMEOUT,
144  
-                                      TestIsTakingTooLong(self.TEST_TIMEOUT))
  147
+        self.timer = Timeout(self.TEST_TIMEOUT,
  148
+                             TestIsTakingTooLong(self.TEST_TIMEOUT))
145 149
 
146 150
     def reset_timeout (self, new_timeout):
147  
-        """Changes the timeout duration; only has effect during one test case"""
148  
-        import evy
149  
-
  151
+        """
  152
+        Changes the timeout duration; only has effect during one test case
  153
+        """
150 154
         self.timer.cancel()
151  
-        self.timer = evy.Timeout(new_timeout,
152  
-                                      TestIsTakingTooLong(new_timeout))
  155
+        self.timer = Timeout(new_timeout, TestIsTakingTooLong(new_timeout))
153 156
 
154 157
     def tearDown (self):
155 158
         self.timer.cancel()
2  tests/stdlib/all_monkey.py
... ...
@@ -1,6 +1,6 @@
1 1
 import evy
2 2
 
3  
-evy.sleep(0)
  3
+sleep(0)
4 4
 from evy import patcher
5 5
 
6 6
 patcher.monkey_patch()
4  tests/test_backdoor.py
@@ -29,8 +29,10 @@
29 29
 
30 30
 
31 31
 import evy
  32
+
32 33
 from evy import backdoor
33 34
 from evy.green import socket
  35
+from evy.greenthread import sleep
34 36
 
35 37
 from tests import LimitedTestCase, main
36 38
 
@@ -56,7 +58,7 @@ def test_server (self):
56 58
         client.close()
57 59
         serv.kill()
58 60
         # wait for the console to discover that it's dead
59  
-        evy.sleep(0.1)
  61
+        sleep(0.1)
60 62
 
61 63
 
62 64
 if __name__ == '__main__':
65  tests/test_convenience.py
@@ -30,9 +30,12 @@
30 30
 
31 31
 import os
32 32
 
33  
-import evy
34 33
 from evy import event
  34
+from evy import convenience
35 35
 from evy.green import socket
  36
+from evy.greenthread import spawn, sleep
  37
+from evy.timeout import with_timeout
  38
+
36 39
 from tests import LimitedTestCase, s2b, skip_if_no_ssl
37 40
 
38 41
 certificate_file = os.path.join(os.path.dirname(__file__), 'server.crt')
@@ -56,9 +59,9 @@ def test_exiting_server (self):
56 59
         def closer (sock, addr):
57 60
             pass
58 61
 
59  
-        l = evy.listen(('localhost', 0))
60  
-        gt = evy.spawn(evy.serve, l, closer)
61  
-        client = evy.connect(('localhost', l.getsockname()[1]))
  62
+        l = convenience.listen(('localhost', 0))
  63
+        gt = spawn(convenience.serve, l, closer)
  64
+        client = convenience.connect(('localhost', l.getsockname()[1]))
62 65
         client.sendall(s2b('a'))
63 66
         self.assertFalse(client.recv(100))
64 67
         gt.kill()
@@ -70,9 +73,9 @@ def crasher (sock, addr):
70 73
             sock.recv(1024)
71 74
             0 // 0
72 75
 
73  
-        l = evy.listen(('localhost', 0))
74  
-        gt = evy.spawn(evy.serve, l, crasher)
75  
-        client = evy.connect(('localhost', l.getsockname()[1]))
  76
+        l = convenience.listen(('localhost', 0))
  77
+        gt = spawn(convenience.serve, l, crasher)
  78
+        client = convenience.connect(('localhost', l.getsockname()[1]))
76 79
         client.sendall(s2b('a'))
77 80
         self.assertRaises(ZeroDivisionError, gt.wait)
78 81
         self.assertFalse(client.recv(100))
@@ -84,9 +87,9 @@ def crasher (sock, addr):
84 87
             sock.close()
85 88
             0 // 0
86 89
 
87  
-        l = evy.listen(('localhost', 0))
88  
-        gt = evy.spawn(evy.serve, l, crasher)
89  
-        client = evy.connect(('localhost', l.getsockname()[1]))
  90
+        l = convenience.listen(('localhost', 0))
  91
+        gt = spawn(convenience.serve, l, crasher)
  92
+        client = convenience.connect(('localhost', l.getsockname()[1]))
90 93
         client.sendall(s2b('a'))
91 94
         self.assertRaises(ZeroDivisionError, gt.wait)
92 95
         self.assertFalse(client.recv(100))
@@ -97,30 +100,30 @@ def test_called_for_each_connection (self):
97 100
         def counter (sock, addr):
98 101
             hits[0] += 1
99 102
 
100  
-        l = evy.listen(('localhost', 0))
101  
-        gt = evy.spawn(evy.serve, l, counter)
  103
+        l = convenience.listen(('localhost', 0))
  104
+        gt = spawn(convenience.serve, l, counter)
102 105
         for i in xrange(100):
103  
-            client = evy.connect(('localhost', l.getsockname()[1]))
  106
+            client = convenience.connect(('localhost', l.getsockname()[1]))
104 107
             self.assertFalse(client.recv(100))
105 108
         gt.kill()
106 109
         self.assertEqual(100, hits[0])
107 110
 
108 111
     def test_blocking (self):
109  
-        l = evy.listen(('localhost', 0))
110  
-        x = evy.with_timeout(0.01,
111  
-                                  evy.serve, l, lambda c, a: None,
  112
+        l = convenience.listen(('localhost', 0))
  113
+        x = with_timeout(0.01,
  114
+                                  convenience.serve, l, lambda c, a: None,
112 115
                                   timeout_value = "timeout")
113 116
         self.assertEqual(x, "timeout")
114 117
 
115 118
     def test_raising_stopserve (self):
116 119
         def stopit (conn, addr):
117  
-            raise evy.StopServe()
  120
+            raise convenience.StopServe()
118 121
 
119  
-        l = evy.listen(('localhost', 0))
  122
+        l = convenience.listen(('localhost', 0))
120 123
         # connect to trigger a call to stopit
121  
-        gt = evy.spawn(evy.connect,
  124
+        gt = spawn(convenience.connect,
122 125
             ('localhost', l.getsockname()[1]))
123  
-        evy.serve(l, stopit)
  126
+        convenience.serve(l, stopit)
124 127
         gt.wait()
125 128
 
126 129
     def test_concurrency (self):
@@ -130,44 +133,42 @@ def waiter (sock, addr):
130 133
             sock.sendall(s2b('hi'))
131 134
             evt.wait()
132 135
 
133  
-        l = evy.listen(('localhost', 0))
134  
-        gt = evy.spawn(evy.serve, l, waiter, 5)
  136
+        l = convenience.listen(('localhost', 0))
  137
+        gt = spawn(convenience.serve, l, waiter, 5)
135 138
 
136 139
         def test_client ():
137  
-            c = evy.connect(('localhost', l.getsockname()[1]))
  140
+            c = convenience.connect(('localhost', l.getsockname()[1]))
138 141
             # verify the client is connected by getting data
139 142
             self.assertEquals(s2b('hi'), c.recv(2))
140 143
             return c
141 144
 
142 145
         clients = [test_client() for i in xrange(5)]
143 146
         # very next client should not get anything
144  
-        x = evy.with_timeout(0.01,
145  
-                                  test_client,
146  
-                                  timeout_value = "timed out")
  147
+        x = with_timeout(0.01, test_client, timeout_value = "timed out")
147 148
         self.assertEquals(x, "timed out")
148 149
 
149 150
     @skip_if_no_ssl
150 151
     def test_wrap_ssl (self):
151  
-        server = evy.wrap_ssl(evy.listen(('localhost', 0)),
  152
+        server = convenience.wrap_ssl(convenience.listen(('localhost', 0)),
152 153
                                    certfile = certificate_file,
153 154
                                    keyfile = private_key_file, server_side = True)
154 155
         port = server.getsockname()[1]
155 156
 
156 157
         def handle (sock, addr):
157 158
             sock.sendall(sock.recv(1024))
158  
-            raise evy.StopServe()
  159
+            raise convenience.StopServe()
159 160
 
160  
-        evy.spawn(evy.serve, server, handle)
161  
-        client = evy.wrap_ssl(evy.connect(('localhost', port)))
  161
+        spawn(convenience.serve, server, handle)
  162
+        client = convenience.wrap_ssl(convenience.connect(('localhost', port)))
162 163
         client.sendall("echo")
163 164
         self.assertEquals("echo", client.recv(1024))
164 165
 
165 166
     def test_socket_reuse (self):
166  
-        lsock1 = evy.listen(('localhost', 0))
  167
+        lsock1 = convenience.listen(('localhost', 0))
167 168
         port = lsock1.getsockname()[1]
168 169
 
169 170
         def same_socket ():
170  
-            return evy.listen(('localhost', port))
  171
+            return convenience.listen(('localhost', port))
171 172
 
172 173
         self.assertRaises(socket.error, same_socket)
173 174
         lsock1.close()
26  tests/test_db_pool.py
@@ -151,7 +151,7 @@ def test_deletion_does_a_put (self):
151 151
     def test_put_doesnt_double_wrap (self):
152 152
         self.pool.put(self.connection)
153 153
         conn = self.pool.get()
154  
-        self.assert_(not isinstance(conn._base, db_pool.PooledConnectionWrapper))
  154
+        self.assert_(not isinstance(conn._base, db_GreenPooledConnectionWrapper))
155 155
         self.pool.put(conn)
156 156
 
157 157
     def test_bool (self):
@@ -356,17 +356,17 @@ def test_max_idle (self):
356 356
         self.connection = self.pool.get()
357 357
         self.connection.close()
358 358
         self.assertEquals(len(self.pool.free_items), 1)
359  
-        evy.sleep(0.01)  # not long enough to trigger the idle timeout
  359
+        sleep(0.01)  # not long enough to trigger the idle timeout
360 360
         self.assertEquals(len(self.pool.free_items), 1)
361 361
         self.connection = self.pool.get()
362 362
         self.connection.close()
363 363
         self.assertEquals(len(self.pool.free_items), 1)
364  
-        evy.sleep(0.01)  # idle timeout should have fired but done nothing
  364
+        sleep(0.01)  # idle timeout should have fired but done nothing
365 365
         self.assertEquals(len(self.pool.free_items), 1)
366 366
         self.connection = self.pool.get()
367 367
         self.connection.close()
368 368
         self.assertEquals(len(self.pool.free_items), 1)
369  
-        evy.sleep(0.03) # long enough to trigger idle timeout for real
  369
+        sleep(0.03) # long enough to trigger idle timeout for real
370 370
         self.assertEquals(len(self.pool.free_items), 0)
371 371
 
372 372
     @skipped
@@ -378,11 +378,11 @@ def test_max_idle_many (self):
378 378
         self.pool = self.create_pool(max_size = 2, max_idle = 0.02)
379 379
         self.connection, conn2 = self.pool.get(), self.pool.get()
380 380
         self.connection.close()
381  
-        evy.sleep(0.01)
  381
+        sleep(0.01)
382 382
         self.assertEquals(len(self.pool.free_items), 1)
383 383
         conn2.close()
384 384
         self.assertEquals(len(self.pool.free_items), 2)
385  
-        evy.sleep(0.02)  # trigger cleanup of conn1 but not conn2
  385
+        sleep(0.02)  # trigger cleanup of conn1 but not conn2
386 386
         self.assertEquals(len(self.pool.free_items), 1)
387 387
 
388 388
     @skipped
@@ -395,12 +395,12 @@ def test_max_age (self):
395 395
         self.connection = self.pool.get()
396 396
         self.connection.close()
397 397
         self.assertEquals(len(self.pool.free_items), 1)
398  
-        evy.sleep(0.01)  # not long enough to trigger the age timeout
  398
+        sleep(0.01)  # not long enough to trigger the age timeout
399 399
         self.assertEquals(len(self.pool.free_items), 1)
400 400
         self.connection = self.pool.get()
401 401
         self.connection.close()
402 402
         self.assertEquals(len(self.pool.free_items), 1)
403  
-        evy.sleep(0.05) # long enough to trigger age timeout
  403
+        sleep(0.05) # long enough to trigger age timeout
404 404
         self.assertEquals(len(self.pool.free_items), 0)
405 405
 
406 406
     @skipped
@@ -413,9 +413,9 @@ def test_max_age_many (self):
413 413
         self.connection, conn2 = self.pool.get(), self.pool.get()
414 414
         self.connection.close()
415 415
         self.assertEquals(len(self.pool.free_items), 1)
416  
-        evy.sleep(0)  # not long enough to trigger the age timeout
  416
+        sleep(0)  # not long enough to trigger the age timeout
417 417
         self.assertEquals(len(self.pool.free_items), 1)
418  
-        evy.sleep(0.2) # long enough to trigger age timeout
  418
+        sleep(0.2) # long enough to trigger age timeout
419 419
         self.assertEquals(len(self.pool.free_items), 0)
420 420
         conn2.close()  # should not be added to the free items
421 421
         self.assertEquals(len(self.pool.free_items), 0)
@@ -438,12 +438,12 @@ def retrieve (pool, ev):
438 438
             ev.send(c)
439 439
 
440 440
         evy.spawn(retrieve, self.pool, e)
441  
-        evy.sleep(0) # these two sleeps should advance the retrieve
442  
-        evy.sleep(0) # coroutine until it's waiting in get()
  441
+        sleep(0) # these two sleeps should advance the retrieve
  442
+        sleep(0) # coroutine until it's waiting in get()
443 443
         self.assertEquals(self.pool.free(), 0)
444 444
         self.assertEquals(self.pool.waiting(), 1)
445 445
         self.pool.put(self.connection)
446  
-        timer = evy.Timeout(1)
  446
+        timer = Timeout(1)
447 447
         conn = e.wait()
448 448
         timer.cancel()
449 449
         self.assertEquals(self.pool.free(), 0)
6  tests/test_debug.py
@@ -150,12 +150,12 @@ def hurl (s):
150 150
         sys.stderr = fake
151 151
         try:
152 152
             gt = evy.spawn(hurl, client_2)
153  
-            evy.sleep(0)
  153
+            sleep(0)
154 154
             client.send(s2b(' '))
155  
-            evy.sleep(0)
  155
+            sleep(0)
156 156
             # allow the "hurl" greenlet to trigger the KeyError
157 157
             # not sure why the extra context switch is needed
158  
-            evy.sleep(0)
  158
+            sleep(0)
159 159
         finally:
160 160
             sys.stderr = orig
161 161
             self.assertRaises(KeyError, gt.wait)
140  tests/test_env.py
... ...
@@ -1,140 +0,0 @@
1  
-#
2  
-# Evy - a concurrent networking library for Python
3  
-#
4  
-# Unless otherwise noted, the files in Evy are under the following MIT license:
5  
-#
6  
-# Copyright (c) 2012, Alvaro Saurin
7  
-# Copyright (c) 2008-2010, Eventlet Contributors (see AUTHORS)
8  
-# Copyright (c) 2007-2010, Linden Research, Inc.
9  
-# Copyright (c) 2005-2006, Bob Ippolito
10  
-#
11  
-# Permission is hereby granted, free of charge, to any person obtaining a copy
12  
-# of this software and associated documentation files (the "Software"), to deal
13  
-# in the Software without restriction, including without limitation the rights
14  
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15  
-# copies of the Software, and to permit persons to whom the Software is
16  
-# furnished to do so, subject to the following conditions:
17  
-#
18  
-# The above copyright notice and this permission notice shall be included in
19  
-# all copies or substantial portions of the Software.
20  
-#
21  
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24  
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26  
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27  
-# THE SOFTWARE.
28  
-#
29  
-
30  
-
31  
-import os
32  
-from tests.test_patcher import ProcessBase
33  
-
34  
-class Socket(ProcessBase):
35  
-    def test_patched_thread (self):
36  
-        new_mod = """from evy.green import socket
37  
-socket.gethostbyname('localhost')
38  
-socket.getaddrinfo('localhost', 80)
39  
-"""
40  
-        os.environ['EVENTLET_TPOOL_DNS'] = 'yes'
41  
-        try:
42  
-            self.write_to_tempfile("newmod", new_mod)
43  
-            output, lines = self.launch_subprocess('newmod.py')
44  
-            self.assertEqual(len(lines), 1, lines)
45  
-        finally:
46  
-            del os.environ['EVENTLET_TPOOL_DNS']
47  
-
48  
-
49  
-class Tpool(ProcessBase):
50  
-    def test_tpool_size (self):
51  
-        expected = "40"
52  
-        normal = "20"
53  
-        new_mod = """from evy import tpool
54  
-import evy
55  
-import time
56  
-current = [0]
57  
-highwater = [0]
58  
-def count():
59  
-    current[0] += 1
60  
-    time.sleep(0.1)
61  
-    if current[0] > highwater[0]:
62  
-        highwater[0] = current[0]
63  
-    current[0] -= 1
64  
-expected = %s
65  
-normal = %s
66  
-p = evy.GreenPool()
67  
-for i in xrange(expected*2):
68  
-    p.spawn(tpool.execute, count)
69  
-p.waitall()
70  
-assert highwater[0] > 20, "Highwater %%s  <= %%s" %% (highwater[0], normal)
71  
-"""
72  
-        os.environ['EVENTLET_THREADPOOL_SIZE'] = expected
73  
-        try:
74  
-            self.write_to_tempfile("newmod", new_mod % (expected, normal))
75  
-            output, lines = self.launch_subprocess('newmod.py')
76  
-            self.assertEqual(len(lines), 1, lines)
77  
-        finally:
78  
-            del os.environ['EVENTLET_THREADPOOL_SIZE']
79  
-
80  
-    def test_tpool_negative (self):
81  
-        new_mod = """from evy import tpool
82  
-import evy
83  
-import time
84  
-def do():
85  
-    print "should not get here"
86  
-try:
87  
-    tpool.execute(do)
88  
-except AssertionError:
89  
-    print "success"
90  
-"""
91  
-        os.environ['EVENTLET_THREADPOOL_SIZE'] = "-1"
92  
-        try:
93  
-            self.write_to_tempfile("newmod", new_mod)
94  
-            output, lines = self.launch_subprocess('newmod.py')
95  
-            self.assertEqual(len(lines), 2, lines)
96  
-            self.assertEqual(lines[0], "success", output)
97  
-        finally:
98  
-            del os.environ['EVENTLET_THREADPOOL_SIZE']
99  
-
100  
-    def test_tpool_zero (self):
101  
-        new_mod = """from evy import tpool
102  
-import evy
103  
-import time
104  
-def do():
105  
-    print "ran it"
106  
-tpool.execute(do)
107  
-"""
108  
-        os.environ['EVENTLET_THREADPOOL_SIZE'] = "0"
109  
-        try:
110  
-            self.write_to_tempfile("newmod", new_mod)
111  
-            output, lines = self.launch_subprocess('newmod.py')
112  
-            self.assertEqual(len(lines), 4, lines)
113  
-            self.assertEqual(lines[-2], 'ran it', lines)
114  
-            self.assert_('Warning' in lines[1] or 'Warning' in lines[0], lines)
115  
-        finally:
116  
-            del os.environ['EVENTLET_THREADPOOL_SIZE']
117  
-
118  
-
119  
-class Hub(ProcessBase):
120  
-    def setUp (self):
121  
-        super(Hub, self).setUp()
122  
-        self.old_environ = os.environ.get('EVENTLET_HUB')
123  
-        os.environ['EVENTLET_HUB'] = 'selects'
124  
-
125  
-    def tearDown (self):
126  
-        if self.old_environ:
127  
-            os.environ['EVENTLET_HUB'] = self.old_environ
128  
-        else:
129  
-            del os.environ['EVENTLET_HUB']
130  
-        super(Hub, self).tearDown()
131  
-
132  
-    def test_evy_hub (self):
133  
-        new_mod = """from evy import hubs
134  
-print hubs.get_hub()
135  
-"""
136  
-        self.write_to_tempfile("newmod", new_mod)
137  
-        output, lines = self.launch_subprocess('newmod.py')
138  
-        self.assertEqual(len(lines), 2, "\n".join(lines))
139  
-        self.assert_("selects" in lines[0])
140  
-
20  tests/test_event.py
@@ -31,7 +31,9 @@
31 31
 import unittest
32 32
 
33 33
 from evy.event import Event
34  
-from evy.api import spawn, sleep, with_timeout
  34
+from evy.greenthread import spawn, spawn_n, sleep, with_timeout
  35
+from evy.timeout import Timeout
  36
+
35 37
 import evy
36 38
 from tests import LimitedTestCase
37 39
 
@@ -63,7 +65,7 @@ def test_send (self):
63 65
         event2 = Event()
64 66
 
65 67
         spawn(event1.send, 'hello event1')
66  
-        evy.Timeout(0, ValueError('interrupted'))
  68
+        Timeout(0, ValueError('interrupted'))
67 69
         try:
68 70
             result = event1.wait()
69 71
         except ValueError:
@@ -79,7 +81,7 @@ def test_waiting_for_event (self):
79 81
         def send_to_event ():
80 82
             evt.send(value)
81 83
 
82  
-        evy.spawn_n(send_to_event)
  84
+        spawn_n(send_to_event)
83 85
         self.assertEqual(evt.wait(), value)
84 86
 
85 87
     def test_multiple_waiters (self):
@@ -104,8 +106,8 @@ def wait_on_event (i_am_done):
104 106
         count = 5
105 107
         for i in range(count):
106 108
             waiters.append(Event())
107  
-            evy.spawn_n(wait_on_event, waiters[-1])
108  
-        evy.sleep()  # allow spawns to start executing
  109
+            spawn_n(wait_on_event, waiters[-1])
  110
+        sleep()  # allow spawns to start executing
109 111
         evt.send()
110 112
 
111 113
         for w in waiters:
@@ -124,7 +126,7 @@ def test_reset (self):
124 126
         def send_to_event ():
125 127
             evt.send(value)
126 128
 
127  
-        evy.spawn_n(send_to_event)
  129
+        spawn_n(send_to_event)
128 130
         self.assertEqual(evt.wait(), value)
129 131
 
130 132
         # now try it again, and we should get the same exact value,
@@ -139,7 +141,7 @@ def send_to_event ():
139 141
         def send_to_event2 ():
140 142
             evt.send(value2)
141 143
 
142  
-        evy.spawn_n(send_to_event2)
  144
+        spawn_n(send_to_event2)
143 145
         self.assertEqual(evt.wait(), value2)
144 146
 
145 147
     def test_double_exception (self):
@@ -150,8 +152,8 @@ def test_double_exception (self):
150 152
         evt.reset()
151 153
 
152 154
         # shouldn't see the RuntimeError again
153  
-        evy.Timeout(0.001)
154  
-        self.assertRaises(evy.Timeout, evt.wait)
  155
+        Timeout(0.001)
  156
+        self.assertRaises(Timeout, evt.wait)
155 157
 
156 158
 
157 159
 if __name__ == '__main__':
8  tests/test_fork.py
@@ -28,7 +28,7 @@
28 28
 #
29 29
 
30 30
 
31  
-from tests.patcher_test import ProcessBase
  31
+from tests.test_patcher import ProcessBase
32 32
 
33 33
 
34 34
 class ForkTest(ProcessBase):
@@ -42,7 +42,7 @@ def test_simple (self):
42 42
 signal_file = os.path.join(mydir, "output.txt")
43 43
 pid = os.fork()
44 44
 if (pid != 0):
45  
-  evy.Timeout(10)
  45
+  Timeout(10)
46 46
   try:
47 47
     port = None
48 48
     while True:
@@ -51,7 +51,7 @@ def test_simple (self):
51 51
         port = int(contents.split()[0])
52 52
         break
53 53
       except (IOError, IndexError, ValueError, TypeError):
54  
-        evy.sleep(0.1)
  54
+        sleep(0.1)
55 55
     evy.connect(('127.0.0.1', port))
56 56
     while True:
57 57
       try:
@@ -59,7 +59,7 @@ def test_simple (self):
59 59
         result = contents.split()[1]
60 60
         break
61 61
       except (IOError, IndexError):
62  
-        evy.sleep(0.1)
  62
+        sleep(0.1)
63 63
     print 'result', result
64 64
   finally:
65 65
     os.kill(pid, signal.SIGTERM)
70  tests/test_green_pool.py
@@ -36,16 +36,18 @@
36 36
 import evy
37 37
 from evy import debug
38 38
 from evy import hubs, greenpool, event
  39
+from evy.greenthread import spawn, sleep
  40
+from evy.timeout import Timeout
39 41
 from evy.support import greenlets as greenlet
40 42
 import tests
41 43
 
42 44
 def passthru (a):
43  
-    evy.sleep(0.01)
  45
+    sleep(0.01)
44 46
     return a
45 47
 
46 48
 
47 49
 def passthru2 (a, b):
48  
-    evy.sleep(0.01)
  50
+    sleep(0.01)
49 51
     return a, b
50 52
 
51 53
 
@@ -67,7 +69,7 @@ def test_spawn_n (self):
67 69
         results_closure = []
68 70
 
69 71
         def do_something (a):
70  
-            evy.sleep(0.01)
  72
+            sleep(0.01)
71 73
             results_closure.append(a)
72 74
 
73 75
         for i in xrange(10):
@@ -88,14 +90,14 @@ def waiter (pool):
88 90
 
89 91
         waiters = []
90 92
         self.assertEqual(pool.running(), 0)
91  
-        waiters.append(evy.spawn(waiter, pool))
92  
-        evy.sleep(0)
  93
+        waiters.append(spawn(waiter, pool))
  94
+        sleep(0)
93 95
         self.assertEqual(pool.waiting(), 0)
94  
-        waiters.append(evy.spawn(waiter, pool))
95  
-        evy.sleep(0)
  96
+        waiters.append(spawn(waiter, pool))
  97
+        sleep(0)
96 98
         self.assertEqual(pool.waiting(), 1)
97  
-        waiters.append(evy.spawn(waiter, pool))
98  
-        evy.sleep(0)
  99
+        waiters.append(spawn(waiter, pool))
  100
+        sleep(0)
99 101
         self.assertEqual(pool.waiting(), 2)
100 102
         self.assertEqual(pool.running(), 1)
101 103
         done.send(None)
@@ -137,8 +139,8 @@ def some_work ():
137 139
         pool = greenpool.GreenPool(2)
138 140
         worker = pool.spawn(some_work)
139 141
         worker.wait()
140  
-        evy.sleep(0)
141  
-        evy.sleep(0)
  142
+        sleep(0)
  143
+        sleep(0)
142 144
         self.assertEquals(timer_fired, [])
143 145
 
144 146
     def test_reentrant (self):
@@ -166,7 +168,7 @@ def assert_pool_has_free (self, pool, num_free):
166 168
         def wait_long_time (e):
167 169
             e.wait()
168 170
 
169  
-        timer = evy.Timeout(1)
  171
+        timer = Timeout(1)
170 172
         try:
171 173
             evt = event.Event()
172 174
             for x in xrange(num_free):
@@ -178,7 +180,7 @@ def wait_long_time (e):
178 180
 
179 181
         # if the runtime error is not raised it means the pool had
180 182
         # some unexpected free items
181  
-        timer = evy.Timeout(0, RuntimeError)
  183
+        timer = Timeout(0, RuntimeError)
182 184
         try:
183 185
             self.assertRaises(RuntimeError, pool.spawn, wait_long_time, evt)
184 186
         finally:
@@ -186,8 +188,8 @@ def wait_long_time (e):
186 188
 
187 189
         # clean up by causing all the wait_long_time functions to return
188 190
         evt.send(None)
189  
-        evy.sleep(0)
190  
-        evy.sleep(0)
  191
+        sleep(0)
  192
+        sleep(0)
191 193
 
192 194
     def test_resize (self):
193 195
         pool = greenpool.GreenPool(2)
@@ -208,8 +210,8 @@ def wait_long_time (e):
208 210
         # cause the wait_long_time functions to return, which will
209 211
         # trigger puts to the pool
210 212
         evt.send(None)
211  
-        evy.sleep(0)
212  
-        evy.sleep(0)
  213
+        sleep(0)
  214
+        sleep(0)
213 215
 
214 216
         self.assertEquals(pool.free(), 1)
215 217
         self.assertEquals(pool.running(), 0)
@@ -232,7 +234,7 @@ def test_pool_smash (self):
232 234
         token = tp.get()  # empty out the pool
233 235
 
234 236
         def do_receive (tp):
235  
-            timer = evy.Timeout(0, RuntimeError())
  237
+            timer = Timeout(0, RuntimeError())
236 238
             try:
237 239
                 t = tp.get()
238 240
                 self.fail("Shouldn't have recieved anything from the pool")
@@ -250,7 +252,7 @@ def do_receive (tp):
250 252
         def send_wakeup (tp):
251 253
             tp.put('wakeup')
252 254
 
253  
-        gt = evy.spawn(send_wakeup, tp)
  255
+        gt = spawn(send_wakeup, tp)
254 256
 
255 257
         # now we ask the pool to run something else, which should not
256 258
         # be affected by the previous send at all
@@ -276,7 +278,7 @@ def foo (a):
276 278
         self.assertEqual(p.free(), 1)
277 279
         gt.wait()
278 280
         self.assertEqual(r, [1])
279  
-        evy.sleep(0)
  281
+        sleep(0)
280 282
         self.assertEqual(p.free(), 2)
281 283