Commits

Denis Bilenko committed 60e92e1

test__threadpool.py: use time.sleep instead of gevent.sleep

  • Participants
  • Parent commits 48d227b

Comments (0)

Files changed (1)

greentest/test__threadpool.py

-from time import time
+from time import time, sleep
 import random
 import greentest
 from gevent.threadpool import ThreadPool
 
 
 def sqr(x, wait=0.0):
-    gevent.sleep(wait)
+    sleep(wait)
     return x * x
 
 
 def sqr_random_sleep(x):
-    gevent.sleep(random.random() * 0.1)
+    sleep(random.random() * 0.1)
     return x * x
 
 
         self.assertEqual(sorted(it), list(map(sqr, range(10))))
 
     def test_terminate(self):
-        result = self.pool.map_async(gevent.sleep, [0.1] * ((self.size or 10) * 2))
+        result = self.pool.map_async(sleep, [0.1] * ((self.size or 10) * 2))
         gevent.sleep(0.1)
         kill = TimingWrapper(self.pool.kill)
         kill()
         result.join()
 
     def sleep(self, x):
-        gevent.sleep(float(x) / 10.)
+        sleep(float(x) / 10.)
         return str(x)
 
     def test_imap_unordered_sleep(self):
         self.pool = ThreadPool(0)
         done = []
         gevent.spawn(self.pool.spawn, done.append, 1)
-        gevent.spawn(self.pool.spawn, done.append, 2)
-        gevent.sleep(0.001)
+        gevent.spawn_later(0.0001, self.pool.spawn, done.append, 2)
+        gevent.sleep(0.01)
         self.assertEqual(done, [])
         self.pool.maxsize = 1
         gevent.sleep(0.001)