示例#1
0
 def response_greenthread():
     with get_connection() as conn:
         with conn.channel() as chan:
             queue = entities.get_topic_queue('test_rpc', 'test', channel=chan)
             queue.declare()
             msg = ifirst(consuming.queue_iterator(queue, no_ack=True, timeout=2))
             msgid, ctx, method, args = context.parse_message(msg.payload)
             sending.reply(conn, msgid, args)
示例#2
0
 def response_greenthread():
     with get_connection() as conn:
         with conn.channel() as chan:
             queue = entities.get_topic_queue('test_rpc',
                                              'test',
                                              channel=chan)
             queue.declare()
             msg = ifirst(
                 consuming.queue_iterator(queue, no_ack=True, timeout=2))
             msgid, ctx, method, args = context.parse_message(msg.payload)
             sending.reply(conn, msgid, args)
示例#3
0
def process_message(connection, delegate, body, reraise=False):
    msgid, ctx, method, args = context.parse_message(body)
    try:
        ret = delegate_apply(delegate, ctx, method, args)
    except Exception:
        exc_typ, exc_val, exc_tb = sys.exc_info()
        if msgid:
            tbfmt = traceback.format_exception(exc_typ, exc_val, exc_tb)
            ret = (exc_typ.__name__, str(exc_val), tbfmt)
            sending.reply(connection, msgid, failure=ret)
        if reraise:
            raise exc_typ, exc_val, exc_tb
    else:
        if msgid:
            sending.reply(connection, msgid, replydata=ret)
示例#4
0
 def listen():
     msg = responses.ifirst(consuming.queue_iterator(
             queue, no_ack=True, timeout=2))
     msg.ack()
     msgid, ctx, method, args = context.parse_message(msg.payload)
     sending.reply(conn, msgid, (method, args))
示例#5
0
 def listen():
     msg = responses.ifirst(
         consuming.queue_iterator(queue, no_ack=True, timeout=2))
     msg.ack()
     msgid, ctx, method, args = context.parse_message(msg.payload)
     sending.reply(conn, msgid, (method, args))