コード例 #1
0
 def test_call(self):
     # Calling a switch_back instance should cause hub.switch() to return
     # with an (args, kwargs) tuple.
     hub = gruvi.get_hub()
     with gruvi.switch_back() as switcher:
         hub.run_callback(lambda: switcher('foo', bar='baz'))
         self.assertEqual(hub.switch(), (('foo', ), {'bar': 'baz'}))
コード例 #2
0
ファイル: test_hub.py プロジェクト: swegener/gruvi
 def test_call(self):
     # Calling a switch_back instance should cause hub.switch() to return
     # with an (args, kwargs) tuple.
     hub = gruvi.get_hub()
     with gruvi.switch_back() as switcher:
         hub.run_callback(lambda: switcher('foo', bar='baz'))
         self.assertEqual(hub.switch(), (('foo',), {'bar': 'baz'}))
コード例 #3
0
ファイル: test_hub.py プロジェクト: swegener/gruvi
 def test_throw(self):
     # An exception thrown with the throw() method of a switch_back instance
     # should cause hub.switch to raise that exception.
     hub = gruvi.get_hub()
     with gruvi.switch_back() as switcher:
         hub.run_callback(lambda: switcher.throw(ValueError('foo')))
         exc = self.assertRaises(ValueError, hub.switch)
         self.assertEqual(exc.args[0], 'foo')
コード例 #4
0
 def test_throw(self):
     # An exception thrown with the throw() method of a switch_back instance
     # should cause hub.switch to raise that exception.
     hub = gruvi.get_hub()
     with gruvi.switch_back() as switcher:
         hub.run_callback(lambda: switcher.throw(ValueError('foo')))
         exc = self.assertRaises(ValueError, hub.switch)
         self.assertEqual(exc.args[0], 'foo')
コード例 #5
0
ファイル: test_hub.py プロジェクト: swegener/gruvi
 def test_many_hubs(self):
     # Create and close a Hub in many threads. If the hub does not garbage
     # collect, then this will run out of file descriptors.
     for i in range(100):
         hub = gruvi.Hub()
         with gruvi.switch_back(timeout=0, hub=hub):
             self.assertRaises(gruvi.Timeout, hub.switch)
         hub.close()
         hub.switch()
         gc.collect()
コード例 #6
0
 def test_many_hubs(self):
     # Create and close a Hub in many threads. If the hub does not garbage
     # collect, then this will run out of file descriptors.
     for i in range(100):
         hub = gruvi.Hub()
         with gruvi.switch_back(timeout=0, hub=hub):
             self.assertRaises(gruvi.Timeout, hub.switch)
         hub.close()
         hub.switch()
         gc.collect()
コード例 #7
0
 def mem_switch_back(self):
     self.add_result(sizeof(gruvi.switch_back(),
                            exclude=('_hub', '_fiber')))
コード例 #8
0
ファイル: test_hub.py プロジェクト: swegener/gruvi
 def test_timeout(self):
     # A timeout in a switch_back instance should cause hub.switch() to
     # raise a Timeout exception.
     hub = gruvi.get_hub()
     with gruvi.switch_back(0.01):
         self.assertRaises(gruvi.Timeout, hub.switch)
コード例 #9
0
 def test_timeout(self):
     # A timeout in a switch_back instance should cause hub.switch() to
     # raise a Timeout exception.
     hub = gruvi.get_hub()
     with gruvi.switch_back(0.01):
         self.assertRaises(gruvi.Timeout, hub.switch)
コード例 #10
0
ファイル: memory.py プロジェクト: Sevenops/gruvi
 def mem_switch_back(self):
     self.add_result(sizeof(gruvi.switch_back(), exclude=('_hub', '_fiber')))