Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import amqp
- import time
- import socket
- conn = amqp.Connection()
- ch = conn.channel()
- print 'Queue should not exist'
- try: ch.basic_consume('e1xpires_test'); print 'fail'
- except: print 'ok'
- ch.queue_declare(queue='e1xpires_test', durable=True, auto_delete=False, arguments={'x-expires': 3000})
- print 'Declared, sleep 1 sec'
- time.sleep(1)
- print 'Start consuming for 1 seconds'
- tag = ch.basic_consume('e1xpires_test')
- try: conn.drain_events(timeout=1)
- except socket.timeout: pass
- ch.basic_cancel(tag)
- time.sleep(0.2)
- print 'Queue should exist'
- try: ch.basic_consume('e1xpires_test'); print "ok"
- except: print "fail"
- time.sleep(2)
- print 'Queue should not exist finally (+2s)'
- try: ch.basic_consume('e1xpires_test'); print 'fail'
- except: print 'ok'
- time.sleep(2)
- print 'Queue should not exist finally (+2s)'
- try: ch.basic_consume('e1xpires_test'); print 'fail'
- except: print 'ok'
- conn.close()
- conn = amqp.Connection()
- ch = conn.channel()
- try: ch.basic_consume('e1xpires_test'); print 'exists after reconnect'
- except: print 'not exists after reconnect'
- time.sleep(5)
- try: ch.basic_consume('e1xpires_test'); print 'exists after reconnect and sleep'
- except: print 'not exists after reconnect and sleep'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement