Exemplo n.º 1
0
    def _testTracingOrProfileState(self, do_pickle=False, **kw):
        t = tasklet(self.Tasklet)
        t(**kw)
        t.run()

        self.foo()
        n = len(self.trace)
        self.foo()
        n2 = len(self.trace)
        self.assertEqual(n, n2)

        if do_pickle:
            io = StringIO()
            p = Pickler(io, -1)
            p.persistent_id = self.persistent_id
            p.dump(t)
            t.remove()
            t.bind(None)
            p = Unpickler(StringIO(io.getvalue()))
            p.persistent_load = self.persistent_load
            t = p.load()
            p = None
            io = None

        t.run()

        self.foo()
        n = len(self.trace)
        self.foo()
        n2 = len(self.trace)
        self.assertEqual(n, n2)
Exemplo n.º 2
0
    def _testTracingOrProfileState(self, do_pickle=False, **kw):
        t = tasklet(self.Tasklet)
        t(**kw)
        t.run()

        self.foo()
        n = len(self.trace)
        self.foo()
        n2 = len(self.trace)
        self.assertEqual(n, n2)

        if do_pickle:
            io = StringIO()
            p = Pickler(io, -1)
            p.persistent_id = self.persistent_id
            p.dump(t)
            t.remove()
            t.bind(None)
            p = Unpickler(StringIO(io.getvalue()))
            p.persistent_load = self.persistent_load
            t = p.load()
            p = None
            io = None

        t.run()

        self.foo()
        n = len(self.trace)
        self.foo()
        n2 = len(self.trace)
        self.assertEqual(n, n2)
Exemplo n.º 3
0
 def testExceptionStatePickled(self):
     if not enable_softswitch(None):
         return
     t = tasklet(self.Tasklet)
     sys.exc_clear()
     t()
     t.run()
     io = StringIO()
     p = Pickler(io, -1)
     p.persistent_id = self.persistent_id
     p.dump(t)
     t.remove()
     t.bind(None)
     p = Unpickler(StringIO(io.getvalue()))
     p.persistent_load = self.persistent_load
     t = p.load()
     p = None
     io = None
     self.ran = False
     t.run()
     self.assertTrue(self.ran)
     ei = sys.exc_info()
     self.assertEqual(ei, (None, ) * 3)
Exemplo n.º 4
0
 def testExceptionStatePickled(self):
     if not enable_softswitch(None):
         return
     t = tasklet(self.Tasklet)
     sys.exc_clear()
     t()
     t.run()
     io = StringIO()
     p = Pickler(io, -1)
     p.persistent_id = self.persistent_id
     p.dump(t)
     t.remove()
     t.bind(None)
     p = Unpickler(StringIO(io.getvalue()))
     p.persistent_load = self.persistent_load
     t = p.load()
     p = None
     io = None
     self.ran = False
     t.run()
     self.assertTrue(self.ran)
     ei = sys.exc_info()
     self.assertEqual(ei, (None,) * 3)