Пример #1
0
    def testSerializableTypes(self):
        # new style callable instance.
        i = TestHandler()
        self.assertNotEquals(None, util.try_deserialize_handler(util.try_serialize_handler(i)))

        i = TestHandlerOldStyle()
        self.assertNotEquals(None, util.try_deserialize_handler(util.try_serialize_handler(i)))
Пример #2
0
    def testSerializableTypes(self):
        # new style callable instance.
        i = TestHandler()
        self.assertNotEquals(
            None, util.try_deserialize_handler(util.try_serialize_handler(i)))

        i = TestHandlerOldStyle()
        self.assertNotEquals(
            None, util.try_deserialize_handler(util.try_serialize_handler(i)))
Пример #3
0
 def testNonSerializableTypes(self):
   # function.
   self.assertEquals(None, util.try_serialize_handler(test_handler_function))
   # Unbound method.
   self.assertEquals(None, util.try_serialize_handler(TestHandler.process))
   # bounded method.
   self.assertEquals(None, util.try_serialize_handler(TestHandler().process))
   # class method.
   self.assertEquals(None, util.try_serialize_handler(TestHandler.process3))
   # staticmethod, which is really a function.
   self.assertEquals(None, util.try_serialize_handler(TestHandler.process2))
Пример #4
0
 def testNonSerializableTypes(self):
     # function.
     self.assertEquals(None,
                       util.try_serialize_handler(test_handler_function))
     # Unbound method.
     self.assertEquals(None,
                       util.try_serialize_handler(TestHandler.process))
     # bounded method.
     self.assertEquals(None,
                       util.try_serialize_handler(TestHandler().process))
     # class method.
     self.assertEquals(None,
                       util.try_serialize_handler(TestHandler.process3))
     # staticmethod, which is really a function.
     self.assertEquals(None,
                       util.try_serialize_handler(TestHandler.process2))
Пример #5
0
 def to_dict(self):
   """Convert state to dictionary to save in task payload."""
   result = {"mapreduce_spec": self.mapreduce_spec.to_json_str(),
             "shard_id": self.shard_id,
             "slice_id": str(self.slice_id),
             "input_reader_state": self.input_reader.to_json_str(),
             "initial_input_reader_state":
             self.initial_input_reader.to_json_str(),
             "retries": str(self.retries)}
   if self.output_writer:
     result["output_writer_state"] = self.output_writer.to_json_str()
   serialized_handler = util.try_serialize_handler(self.handler)
   if serialized_handler:
     result["serialized_handler"] = serialized_handler
   return result
Пример #6
0
 def to_dict(self):
   """Convert state to dictionary to save in task payload."""
   result = {"mapreduce_spec": self.mapreduce_spec.to_json_str(),
             "shard_id": self.shard_id,
             "slice_id": str(self.slice_id),
             "input_reader_state": self.input_reader.to_json_str(),
             "initial_input_reader_state":
             self.initial_input_reader.to_json_str(),
             "retries": str(self.retries)}
   if self.output_writer:
     result["output_writer_state"] = self.output_writer.to_json_str()
   serialized_handler = util.try_serialize_handler(self.handler)
   if serialized_handler:
     result["serialized_handler"] = serialized_handler
   return result