SHARE
TWEET

Untitled

a guest May 31st, 2014 288 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #setup queue
  2. connection = pika.BlockingConnection(pika.ConnectionParameters(host='0.0.0.0'))
  3. channel = connection.channel()
  4.  
  5. print("connection: " + str(connection))
  6.  
  7. from twit.models.twitter import Tweet
  8. import time
  9.  
  10. def consume_callback(ch, method, properties, body):
  11.     print(" [x] Received %r" % (body,))
  12.     # tasks.store_tweet.delay(body.text, body.created_at, body.screen_name)
  13.  
  14.     t = Tweet()
  15.     t.text = body.text
  16.     t.created_at = body.created_at
  17.     t.screen_name = body.screen_name
  18.     DBSession.add(t)
  19.  
  20.     print " [x] Done"
  21.     ch.basic_ack(delivery_tag = method.delivery_tag)
  22.  
  23. channel.basic_qos(prefetch_count=1)
  24. channel.basic_consume(consume_callback,
  25.                       queue='twitter_topic_feed')
  26.  
  27. channel.start_consuming()
  28.  
  29.  
  30. LOG:
  31.  
  32. 2014-05-31 11:35:46,338 INFO  [pika.adapters.base_connection][MainThread] Connecting to 0.0.0.0:5672
  33. connection: <pika.adapters.blocking_connection.BlockingConnection object at 0x10b54aa90>
  34.  [x] Received '{"text": "@CMPunkisBITW @ddlovato the car is a whale? Okay then...", "created_at": 1401564953.0, "screen_name": "BeautifulDemiD"}'
  35. Traceback (most recent call last):
  36.   File "../bin/pserve", line 9, in <module>
  37.     load_entry_point('pyramid==1.5', 'console_scripts', 'pserve')()
  38.   File "/Users/Shared/webapp/twit_env/lib/python2.7/site-packages/pyramid-1.5-py2.7.egg/pyramid/scripts/pserve.py", line 51, in main
  39.     return command.run()
  40.   File "/Users/Shared/webapp/twit_env/lib/python2.7/site-packages/pyramid-1.5-py2.7.egg/pyramid/scripts/pserve.py", line 316, in run
  41.     global_conf=vars)
  42.   File "/Users/Shared/webapp/twit_env/lib/python2.7/site-packages/pyramid-1.5-py2.7.egg/pyramid/scripts/pserve.py", line 340, in loadapp
  43.     return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
  44.   File "/Users/Shared/webapp/twit_env/lib/python2.7/site-packages/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 247, in loadapp
  45.     return loadobj(APP, uri, name=name, **kw)
  46.   File "/Users/Shared/webapp/twit_env/lib/python2.7/site-packages/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 272, in loadobj
  47.     return context.create()
  48.   File "/Users/Shared/webapp/twit_env/lib/python2.7/site-packages/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 710, in create
  49.     return self.object_type.invoke(self)
  50.   File "/Users/Shared/webapp/twit_env/lib/python2.7/site-packages/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 146, in invoke
  51.     return fix_call(context.object, context.global_conf, **context.local_conf)
  52.   File "/Users/Shared/webapp/twit_env/lib/python2.7/site-packages/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/util.py", line 55, in fix_call
  53.     val = callable(*args, **kw)
  54.   File "/Users/Shared/webapp/twit_env/twit/twit/__init__.py", line 61, in main
  55.     config.scan("twit.views")
  56.   File "/Users/Shared/webapp/twit_env/lib/python2.7/site-packages/pyramid-1.5-py2.7.egg/pyramid/config/__init__.py", line 929, in scan
  57.     ignore=ignore)
  58.   File "/Users/Shared/webapp/twit_env/lib/python2.7/site-packages/venusian-1.0a8-py2.7.egg/venusian/__init__.py", line 199, in scan
  59.     __import__(modname)
  60.   File "/Users/Shared/webapp/twit_env/twit/twit/views/api.py", line 710, in <module>
  61.     channel.start_consuming()
  62.   File "/Users/Shared/webapp/twit_env/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 917, in start_consuming
  63.     self.connection.process_data_events()
  64.   File "/Users/Shared/webapp/twit_env/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 218, in process_data_events
  65.     raise exceptions.ConnectionClosed()
  66. pika.exceptions.ConnectionClosed
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top