Advertisement
datacompboy

Untitled

Jun 11th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. import amqp
  2. import time
  3. import socket
  4.  
  5. conn = amqp.Connection()
  6. ch = conn.channel()
  7.  
  8. print 'Queue should not exist'
  9. try: ch.basic_consume('e1xpires_test'); print 'fail'
  10. except: print 'ok'
  11. ch.queue_declare(queue='e1xpires_test', durable=True, auto_delete=False, arguments={'x-expires': 3000})
  12. print 'Declared, sleep 1 sec'
  13. time.sleep(1)
  14. print 'Start consuming for 1 seconds'
  15. tag = ch.basic_consume('e1xpires_test')
  16. try: conn.drain_events(timeout=1)
  17. except socket.timeout: pass
  18. ch.basic_cancel(tag)
  19.  
  20. time.sleep(0.2)
  21. print 'Queue should exist'
  22. try: ch.basic_consume('e1xpires_test'); print "ok"
  23. except: print "fail"
  24.  
  25. time.sleep(2)
  26. print 'Queue should not exist finally (+2s)'
  27. try: ch.basic_consume('e1xpires_test'); print 'fail'
  28. except: print 'ok'
  29.  
  30. time.sleep(2)
  31. print 'Queue should not exist finally (+2s)'
  32. try: ch.basic_consume('e1xpires_test'); print 'fail'
  33. except: print 'ok'
  34.  
  35. conn.close()
  36. conn = amqp.Connection()
  37. ch = conn.channel()
  38.  
  39. try: ch.basic_consume('e1xpires_test'); print 'exists after reconnect'
  40. except: print 'not exists after reconnect'
  41. time.sleep(5)
  42. try: ch.basic_consume('e1xpires_test'); print 'exists after reconnect and sleep'
  43. except: print 'not exists after reconnect and sleep'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement