Esempio n. 1
0
 def __iter__(self):
     parent = getcurrent().parent
     pool = self.greenpool
     while True:
         if parent:
             yield self._read_body()
         else:
             yield pool.submit(self._read_body)
         if not self._data:
             break
Esempio n. 2
0
    def test_lock(self):
        green = greenio.getcurrent()
        lock = greenio.GreenLock()
        self.assertTrue(lock.acquire())
        self.assertEqual(lock.locked(), green)
        #
        # create a new greenlet
        child = greenio.greenlet(self._test_lock)
        future = child.switch(lock)

        self.assertIsInstance(future, Future)
        self.assertEqual(lock.locked(), green)

        # release the lock
        lock.release()
        self.assertTrue(future.done())
        self.assertEqual(lock.locked(), green)
Esempio n. 3
0
    def test_lock(self):
        green = greenio.getcurrent()
        lock = greenio.GreenLock()
        self.assertTrue(lock.acquire())
        self.assertEqual(lock.locked(), green)
        #
        # create a new greenlet
        child = greenio.greenlet(self._test_lock)
        future = child.switch(lock)

        self.assertIsInstance(future, Future)
        self.assertEqual(lock.locked(), green)

        # release the lock
        lock.release()
        self.assertTrue(future.done())
        self.assertEqual(lock.locked(), green)
Esempio n. 4
0
 def test_lock(self):
     lock = greenio.GreenLock()
     self.assertTrue(lock.acquire())
     self.assertEqual(lock.locked(), greenio.getcurrent())
     lock.release()
     self.assertFalse(lock.locked())