예제 #1
0
 def loop(self):
     i = 0
     echo = self.proxy('iris://echo', timeout=2)
     while True:
         gevent.sleep(self.delay)
         trace.set_id()
         try:
             result = echo.upper(text='foo_%s' % i)
         except iris.RpcError:
             continue
         print("result = %s" % result)
         i += 1
예제 #2
0
파일: container.py 프로젝트: lowks/lymph
 def recv_message(self, msg):
     trace.set_id(msg.headers.get('trace_id'))
     logger.debug('<- %s %r', msg, msg.headers)
     connection = self.connect(msg.source)
     connection.on_recv(msg)
     if msg.is_request():
         self.spawn(self.dispatch_request, msg)
     elif msg.is_reply():
         try:
             channel = self.channels[msg.subject]
         except KeyError:
             logger.debug('reply to unknown subject: %s (msg-id=%s)', msg.subject, msg.id)
             return
         channel.recv(msg)
     else:
         logger.warning('unknown message type: %s (msg-id=%s)', msg.type, msg.id)
예제 #3
0
 def recv_message(self, msg):
     trace.set_id(msg.headers.get('trace_id'))
     logger.debug('<- %s %r', msg, msg.headers)
     connection = self.connect(msg.source)
     connection.on_recv(msg)
     if msg.is_request():
         self.pool.spawn(self.dispatch_request, msg)
     elif msg.is_reply():
         try:
             channel = self.channels[msg.subject]
         except KeyError:
             logger.debug('reply to unknown subject: %s (msg-id=%s)', msg.subject, msg.id)
             return
         channel.recv(msg)
     else:
         logger.warning('unknown message type: %s (msg-id=%s)', msg.type, msg.id)
예제 #4
0
파일: interfaces.py 프로젝트: lowks/lymph
 def dispatch_request(self, request):
     trace.set_id()
     urls = self.url_map.bind_to_environ(request.environ)
     request.urls = urls
     try:
         endpoint, args = urls.match()
         if callable(endpoint):
             handler = endpoint(self, request)
             response = handler.dispatch(args)
         else:
             try:
                 handler = getattr(self, endpoint)
             except AttributeError:
                 raise  # FIXME
             response = handler(request, **args)
     except HTTPException as e:
         response = e.get_response(request.environ)
     return response
예제 #5
0
 def dispatch_request(self, request):
     trace.set_id()
     urls = self.url_map.bind_to_environ(request.environ)
     request.urls = urls
     try:
         endpoint, args = urls.match()
         if callable(endpoint):
             handler = endpoint(self, request)
             response = handler.dispatch(args)
         else:
             try:
                 handler = getattr(self, endpoint)
             except AttributeError:
                 raise  # FIXME
             response = handler(request, **args)
     except HTTPException as e:
         response = e.get_response(request.environ)
     return response