Exemplo n.º 1
0
 def _service_handle(self, buf):
     service, arg = call.decode_req(buf)
     with self.lock:
         if service in self.service_handlers:
             hanlder = self.service_handlers[service]
         else:
             return call.encode_res_error("service doesn't exist")
     try:
         return call.encode_res(hanlder(arg))
     except ServiceFailed as e:
         return call.encode_res_error(str(e))
Exemplo n.º 2
0
 def _service_handle(self, buf):
     service, arg = call.decode_req(buf)
     with self.lock:
         if service in self.service_handlers:
             hanlder = self.service_handlers[service]
         else:
             return call.encode_res_error("service doesn't exist")
     try:
         return call.encode_res(hanlder(arg))
     except ServiceFailed as e:
         return call.encode_res_error(str(e))
Exemplo n.º 3
0
 def test_decode_res_err(self):
     with self.assertRaises(call.CallFailed):
         call.decode_res(call.encode_res_error('error'))
Exemplo n.º 4
0
 def test_encode_err(self):
     self.assertEqual(msgpack.packb(['err', 'error message']),
                      call.encode_res_error('error message'))
Exemplo n.º 5
0
 def test_decode_res_err(self):
     with self.assertRaises(call.CallFailed):
         call.decode_res(call.encode_res_error('error'))
Exemplo n.º 6
0
 def test_encode_err(self):
     self.assertEqual(msgpack.packb(['err', 'error message']),
                      call.encode_res_error('error message'))