def swapContents(): numbersStream = giopen(self.tempdir+'/1', 'rw') lettersStream = giopen(self.tempdir+'/2', 'rw') with numbersStream: numbers = yield with lettersStream: letters = yield yield numbers yield letters done.append(True)
def swapContents(): numbersStream = giopen(self.tempdir + '/1', 'rw') lettersStream = giopen(self.tempdir + '/2', 'rw') with numbersStream: numbers = yield with lettersStream: letters = yield yield numbers yield letters done.append(True)
def handler(): with giopen(self.tempfile, 'rw'): with Timer(0.1): try: for i in xrange(999999): yield 'a' except TimeoutException: done.append(False) yield
def XXXXXXXXXXXXXtestNeverExittedContextIsForcedToExitByGeneratorExitWhileReading(self): context = giopen(self.tempfile, 'rw') def neverExit(): with context: while True: # never exit context, unless with exception yield proc = neverExit() g = Gio(self.reactor, proc) self.reactor.step() try: proc.throw(GeneratorExit()) # force exit outside Gio() self.fail('Must not come here') except GeneratorExit: pass self.assertEquals([], g._contextstack)
def XXXXXXXXXXXXXtestNeverExittedContextIsForcedToExitByGeneratorExitWhileReading( self): context = giopen(self.tempfile, 'rw') def neverExit(): with context: while True: # never exit context, unless with exception yield proc = neverExit() g = Gio(self.reactor, proc) self.reactor.step() try: proc.throw(GeneratorExit()) # force exit outside Gio() self.fail('Must not come here') except GeneratorExit: pass self.assertEquals([], g._contextstack)
def testOpenReturnsContextManager(self): result = giopen('http/data/testdata5kb') self.assertTrue(hasattr(result, '__enter__')) self.assertTrue(hasattr(result, '__exit__'))
def myProcessor(): with giopen(self.tempfile, 'rw') as datastream: self.assertTrue(isinstance(datastream, Context)) self.dataIn = yield yield 'write this!'
def handler(): with giopen(self.tempfile, 'rw'): with Timer(0.1): yield 'a' yield 'b' done.append(True)