Skip to content

Instantly share code, notes, and snippets.

@tarzanjw
Created June 26, 2014 04:52
Show Gist options
  • Save tarzanjw/a8116c603b41838ec065 to your computer and use it in GitHub Desktop.
Save tarzanjw/a8116c603b41838ec065 to your computer and use it in GitHub Desktop.
Error with waitress and cassandra
2014-06-26 11:39:58,681 DEBUG [cassandra.cluster][MainThread] [control connection] Opening new connection to 10.0.0.131
2014-06-26 11:39:58,693 DEBUG [cassandra.cluster][MainThread] [control connection] Established new connection <AsyncoreConnection(26400848) 10.0.0.131:9042>, registering watchers and refreshing schema and topology
2014-06-26 11:39:58,815 DEBUG [cassandra.cluster][MainThread] [control connection] Refreshing node list and token map using preloaded results
2014-06-26 11:39:58,815 DEBUG [cassandra.cluster][MainThread] [control connection] Finished fetching ring info
2014-06-26 11:39:58,815 DEBUG [cassandra.cluster][MainThread] [control connection] Rebuilding token map due to topology changes
2014-06-26 11:39:58,817 DEBUG [cassandra.cluster][MainThread] [control connection] Attempting to use preloaded results for schema agreement
2014-06-26 11:39:58,817 DEBUG [cassandra.cluster][MainThread] [control connection] Schemas match
2014-06-26 11:39:59,191 DEBUG [cassandra.cluster][MainThread] [control connection] Fetched schema, rebuilding metadata
2014-06-26 11:39:59,232 DEBUG [cassandra.cluster][MainThread] Control connection created
2014-06-26 11:39:59,265 DEBUG [cassandra.cluster][Thread-2] Added pool for host 10.0.0.131 to session
2014-06-26 11:39:59,268 DEBUG [cassandra.cluster][Thread-1] Added pool for host 10.0.0.132 to session
2014-06-26 11:39:59,312 DEBUG [cassandra.cluster][Thread-2] Added pool for host 10.0.0.130 to session
serving on http://0.0.0.0:8080
2014-06-26 11:40:12,096 ERROR [waitress][cassandra_driver_event_loop] Socket error
Traceback (most recent call last):
File "/home/tarzan/.virtualenvs/lab/local/lib/python2.7/site-packages/waitress-0.8.8-py2.7.egg/waitress/channel.py", line 167, in handle_read
data = self.recv(self.adj.recv_bytes)
File "/usr/lib/python2.7/asyncore.py", line 387, in recv
data = self.socket.recv(buffer_size)
error: [Errno 11] Resource temporarily unavailable
2014-06-26 11:40:15,711 ERROR [waitress][cassandra_driver_event_loop] Socket error
Traceback (most recent call last):
File "/home/tarzan/.virtualenvs/lab/local/lib/python2.7/site-packages/waitress-0.8.8-py2.7.egg/waitress/channel.py", line 167, in handle_read
data = self.recv(self.adj.recv_bytes)
File "/usr/lib/python2.7/asyncore.py", line 387, in recv
data = self.socket.recv(buffer_size)
error: [Errno 11] Resource temporarily unavailable
2014-06-26 11:40:24,765 ERROR [waitress][MainThread] Unexpected exception when flushing
Traceback (most recent call last):
File "/home/tarzan/.virtualenvs/lab/local/lib/python2.7/site-packages/waitress-0.8.8-py2.7.egg/waitress/channel.py", line 140, in handle_write
flush()
File "/home/tarzan/.virtualenvs/lab/local/lib/python2.7/site-packages/waitress-0.8.8-py2.7.egg/waitress/channel.py", line 259, in _flush_some
outbuf.skip(num_sent, True)
File "/home/tarzan/.virtualenvs/lab/local/lib/python2.7/site-packages/waitress-0.8.8-py2.7.egg/waitress/buffers.py", line 274, in skip
buf.skip(numbytes, allow_prune)
File "/home/tarzan/.virtualenvs/lab/local/lib/python2.7/site-packages/waitress-0.8.8-py2.7.egg/waitress/buffers.py", line 77, in skip
numbytes, self.remain)
ValueError: Can't skip 270 bytes in buffer of 0 bytes
import logging
from waitress import serve
from pyramid.config import Configurator
from datetime import datetime
from cassandra.cluster import Cluster
# setup logging
logging.basicConfig(
format='%(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s'
)
cf_logger = logging.getLogger('cassandra.cluster')
cf_logger.setLevel(logging.DEBUG)
waitress_logger = logging.getLogger('waitress')
waitress_logger.setLevel(logging.DEBUG)
# setup cassandra cluster
cluster = Cluster(['10.0.0.130', '10.0.0.131', '10.0.0.132'])
session = cluster.connect('system')
def home_view(request):
rows = session.execute('select * from peers;')
return {
'now': str(datetime.now()),
'hosts': [str(r[2]) for r in rows],
}
def make_wsgi_app(settings=None):
settings = settings or {}
config = Configurator(settings=settings)
config.add_route('home', '/')
config.add_view(home_view, route_name='home', renderer='json')
return config.make_wsgi_app()
serve(make_wsgi_app(), port='8080')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment