示例#1
0
 def request(self, method, params=()):
     """
         Request from peer
         @method:
             name of method requested
         @params:
             tuple params passed to method
     """
     
     if not isinstance(params, tuple):
         params = (params,)
     
     xmlout = xmlpickler_dumps(params, method)
     size = len(xmlout)
     head = BEGIN_XMLREQUEST_HEADER % (self.currid, size)
     
     self.send_lock.acquire() #acquire thread lock
     
     try:
         self.session.send(head)
         self.session.send(xmlout)
         self.session.send(END_XMLREQUEST_HEADER)
         has_error = False
     except Exception, error:
         has_error = True
         self.logger.error(error)
         traceback.print_exc()
示例#2
0
 def request(self, method, params=()):
     """
         Request from peer
         @method:
             name of method requested
         @params:
             tuple params passed to method
     """
     if not isinstance(params, tuple):
         params = (params,)
     
     xmlout = xmlpickler_dumps(params, method)
     size = len(xmlout)
     
     head = BEGIN_XMLREQUEST_HEADER % (self.currid, size)
     self.send_lock.acquire()
     self.session.send(head)
     self.session.send(xmlout)
     self.session.send(END_XMLREQUEST_HEADER)
     
     try:
         self.send_lock.release()
     except:
         pass
     
     response = Response(self.currid)
     self.open_responses[self.currid] = response
     self.currid += 1
     
     return response
示例#3
0
 def request(self, method, params=()):
     """
         Request from peer
         @method:
             name of method requested
         @params:
             tuple params passed to method
     """
     
     if not isinstance(params, tuple):
         params = (params,)
     
     xmlout = xmlpickler_dumps(params, method)
     size = len(xmlout)
     head = BEGIN_XMLREQUEST_HEADER % (self.currid, size)
     
     self.send_lock.acquire() #acquire thread lock
     
     try:
         self.session.send(head)
         self.session.send(xmlout)
         self.session.send(END_XMLREQUEST_HEADER)
         has_error = False
     except Exception, error:
         has_error = True
         self.logger.error(error)
         traceback.print_exc()
示例#4
0
 def request(self, method, params=()):
     """
         Request from peer
         @method:
             name of method requested
         @params:
             tuple params passed to method
     """
     if not isinstance(params, tuple):
         params = (params,)
     
     xmlout = xmlpickler_dumps(params, method)
     size = len(xmlout)
     
     head = BEGIN_XMLREQUEST_HEADER % (self.currid, size)
     self.send_lock.acquire()
     self.session.send(head)
     self.session.send(xmlout)
     self.session.send(END_XMLREQUEST_HEADER)
     
     try:
         self.send_lock.release()
     except:
         pass
     
     response = Response(self.currid)
     self.open_responses[self.currid] = response
     self.currid += 1
     
     return response
示例#5
0
 def send_response(self, id, response):
     """
         Send Response to peer
     """
     
     try:
         output = xmlpickler_dumps((response,), methodresponse=1)
         head = BEGIN_XMLRESPONSE_HEADER % (id, len(output))
         self.send_lock.acquire()
         self.session.send(head)
         self.session.send(output)
         self.session.send(END_XMLRESPONSE_HEADER)
         
     except Exception, error:
         self.logger.error(error)
示例#6
0
 def send_response(self, id, response):
     """
         Send Response to peer
     """
     
     try:
         output = xmlpickler_dumps((response,), methodresponse=1)
         head = BEGIN_XMLRESPONSE_HEADER % (id, len(output))
         self.send_lock.acquire()
         self.session.send(head)
         self.session.send(output)
         self.session.send(END_XMLRESPONSE_HEADER)
         
     except Exception, error:
         self.logger.error(error)