Esempio n. 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)
Esempio n. 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)
Esempio n. 3
0
def test_replying(connection):
    with connection as conn:
        msgid = uuid.uuid4().hex
        with conn.channel() as chan:
            queue = entities.get_reply_queue(msgid=msgid, channel=chan)
            queue.declare()

            sending.reply(conn, msgid, 'success')
            msg = ifirst(
                consuming.queue_iterator(queue, no_ack=True, timeout=0.2))
            assert msg.payload['result'] == 'success'

    # check consumefrom has removed entry
    assert not consuming._conndrainers
Esempio n. 4
0
def test_replying(connection):
    with connection as conn:
        msgid = uuid.uuid4().hex
        with conn.channel() as chan:
            queue = entities.get_reply_queue(msgid=msgid,
                    channel=chan)
            queue.declare()

            sending.reply(conn, msgid, 'success')
            msg = ifirst(consuming.queue_iterator(queue, no_ack=True, timeout=0.2))
            assert msg.payload['result'] == 'success'

    # check consumefrom has removed entry
    assert not consuming._conndrainers
Esempio n. 5
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)
Esempio n. 6
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))
Esempio n. 7
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))