Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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
Пример #4
0
 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)
Пример #5
0
    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)
Пример #6
0
 def testOpenReturnsContextManager(self):
     result = giopen('http/data/testdata5kb')
     self.assertTrue(hasattr(result, '__enter__'))
     self.assertTrue(hasattr(result, '__exit__'))
Пример #7
0
 def myProcessor():
     with giopen(self.tempfile, 'rw') as datastream:
         self.assertTrue(isinstance(datastream, Context))
         self.dataIn = yield
         yield 'write this!'
Пример #8
0
 def testOpenReturnsContextManager(self):
     result = giopen('http/data/testdata5kb')
     self.assertTrue(hasattr(result, '__enter__'))
     self.assertTrue(hasattr(result, '__exit__'))
Пример #9
0
 def myProcessor():
     with giopen(self.tempfile, 'rw') as datastream:
         self.assertTrue(isinstance(datastream, Context))
         self.dataIn = yield
         yield 'write this!'
Пример #10
0
 def handler():
     with giopen(self.tempfile, 'rw'):
         with Timer(0.1):
             yield 'a'
         yield 'b'
     done.append(True)