def pickled_runner(q, pickled, args, kwargs, **kw): wrapper = kw.pop('wrapper', None) impl = kwargs.pop('impl', 'CP3') if wrapper: wrapper = loads(wrapper) else: wrapper = lambda v, a, kw: v(*a, **kw) deserial = loads(base64.b64decode(pickled), impl=impl) q.put(wrapper(deserial, args, kwargs))
def pickled_runner(q, pickled, args, kwargs, **kw): try: wrapper = kw.pop('wrapper', None) impl = kwargs.pop('impl', (3, 5, 'cpython')) if wrapper: wrapper = loads(wrapper) else: wrapper = lambda v, a, kw: v(*a, **kw) deserial = loads(base64.b64decode(pickled), impl=impl) q.put(wrapper(deserial, args, kwargs)) except: traceback.print_exc() raise
def testNestedClassObj(self): func = _gen_nested_yield_obj() obj_serial = base64.b64encode(dumps(func)) deserial = loads(base64.b64decode(obj_serial)) self.assertEqual(sum(deserial()(20)), sum(func()(20)))
def testNestedFunc(self): func = _gen_nested_fun() obj_serial = base64.b64encode(dumps(func)) deserial = loads(base64.b64decode(obj_serial)) self.assertEqual(deserial(20), func(20))
def testRangeObject(self): obj_serial = dumps(range(10)) deserial = loads(obj_serial) self.assertListEqual(list(range(10)), list(deserial))