python - Pyramid and Cassandra don't work properly -


i using pyramid (1.5.7), waitress (0.8.9) cassandra (2.2.0). seems waitress , cassandra driver using both asyncore , somehow stepping on each others toes. code on app/__init__.py file:

import logging.config .action.context import root_factory pyramid.config import configurator cassandra.cluster import cluster cassandra.query import named_tuple_factory   def main(global_config, **settings):     """ function returns pyramid wsgi application."""      # support logging in python3     logging.config.fileconfig(         settings['logging.config'],         disable_existing_loggers=false     )     config = configurator(settings=settings, root_factory=root_factory)     # retrieves connection cassandra (non sql database)     def get_non_sql(request):         cluster = cluster(['127.0.0.1'], port=9042)         session = cluster.connect('app')         def disconnect(request):             cluster.shutdown()         request.add_finished_callback(disconnect)         return cluster.connect('app')      #adding scheduler configuration     config.configure_celery(global_config['__file__'])     config.add_request_method(get_non_sql, 'non_sql', reify=true)     config.scan()     return config.make_wsgi_app() 

generated errors:

2015-07-27 12:24:36,779 error [waitress][cassandra_driver_event_loop] socket error. traceback (most recent call last):   file "python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py", line 167, in handle_read     data = self.recv(self.adj.recv_bytes)   file "python3.4/asyncore.py", line 379, in recv     data = self.socket.recv(buffer_size) blockingioerror: [errno 35] resource temporarily unavailable 2015-07-27 12:24:37,079 error [waitress][mainthread] unexpected exception when flushing.   file "python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/server.py", line 154, in run     use_poll=self.adj.asyncore_use_poll,   file "python3.4/asyncore.py", line 208, in loop     poll_fun(timeout, map)   file "python3.4/asyncore.py", line 145, in poll     r, w, e = select.select(r, w, e, timeout) oserror: [errno 9] bad file descriptor 2015-07-27 12:33:32,649 debug [cassandra.io.asyncorereactor][cassandra_driver_event_loop] asyncore event loop ended 

does know workaround issue?

waitress , cassandra-driver using same socket. i've deleted version 0.8.9 of waitress , installed latest development version (master branch)

pip uninstall waitress pip install git+git://github.com/pylons/waitress@master 

the asyncore socket has been changed in version works perfectly. nonetheless recommend using libev instead, seems have better performance asyncore. in os x it's easy installing libev library:

brew install libev 

right after doing this, install cassandra-driver (it detect libev library automatically)

pip install cassandra-driver 

and use libevconnection class:

from cassandra.io.libevreactor import libevconnection  cassandra.cluster import cluster    cluster = cluster()  cluster.connection_class = libevconnection  session = cluster.connect() 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -