{"action":"created","issue":{"url":"https://api.github.com/repos/Pylons/waitress/issues/106","labels_url":"https://api.github.com/repos/Pylons/waitress/issues/106/labels{/name}","comments_url":"https://api.github.com/repos/Pylons/waitress/issues/106/comments","events_url":"https://api.github.com/repos/Pylons/waitress/issues/106/events","html_url":"https://github.com/Pylons/waitress/issues/106","id":97440594,"number":106,"title":"Cassandra compatibility issue","user":{"login":"AnderUstarroz","id":8544110,"avatar_url":"https://avatars.githubusercontent.com/u/8544110?v=3","gravatar_id":"","url":"https://api.github.com/users/AnderUstarroz","html_url":"https://github.com/AnderUstarroz","followers_url":"https://api.github.com/users/AnderUstarroz/followers","following_url":"https://api.github.com/users/AnderUstarroz/following{/other_user}","gists_url":"https://api.github.com/users/AnderUstarroz/gists{/gist_id}","starred_url":"https://api.github.com/users/AnderUstarroz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnderUstarroz/subscriptions","organizations_url":"https://api.github.com/users/AnderUstarroz/orgs","repos_url":"https://api.github.com/users/AnderUstarroz/repos","events_url":"https://api.github.com/users/AnderUstarroz/events{/privacy}","received_events_url":"https://api.github.com/users/AnderUstarroz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-27T11:17:40Z","updated_at":"2015-07-27T16:24:27Z","closed_at":null,"body":"Seems like theres is a compatibility issue between Waitress and Cassandra. Both are using asyncore and somehow they are stepping on each others toes. This is my code:\r\n\r\n\timport logging.config\r\n\tfrom .action.context import root_factory\r\n\tfrom pyramid.config import Configurator\r\n\tfrom cassandra.cluster import Cluster\r\n\tfrom cassandra.query import named_tuple_factory\r\n\r\n\r\n\tdef main(global_config, **settings):\r\n\t    \"\"\" This function returns a Pyramid WSGI application.\"\"\"\r\n\r\n\t    # support logging in python3\r\n\t    logging.config.fileConfig(\r\n\t        settings['logging.config'],\r\n\t        disable_existing_loggers=False\r\n\t    )\r\n\t    config = Configurator(settings=settings, root_factory=root_factory)\r\n\t    # Retrieves connection to Cassandra (Non SQL database)\r\n\t    def get_non_sql(request):\r\n\t        cluster = Cluster(['127.0.0.1'], port=9042)\r\n\t        def disconnect(request):\r\n\t            cluster.shutdown()\r\n\t        request.add_finished_callback(disconnect)\r\n\t        return cluster.connect('app')\r\n\r\n\t    #Adding scheduler configuration\r\n\t    config.configure_celery(global_config['__file__'])\r\n\t    config.add_request_method(get_non_sql, 'non_sql', reify=True)\r\n\t    config.scan()\r\n\t    return config.make_wsgi_app()\r\n\r\nWhenever I try to run a query it actually works but it  throws  many errors afterwards:\r\n\r\n    2015-07-27 12:24:36,703 DEBUG [cassandra.io.asyncorereactor][Dummy-6] Closing connection (4384473384) to 127.0.0.1\r\n\t2015-07-27 12:24:36,705 DEBUG [cassandra.cluster][Task Scheduler] Not executing scheduled task due to Scheduler shutdown\r\n\t2015-07-27 12:24:36,706 DEBUG [cassandra.io.asyncorereactor][Dummy-6] Closed socket to 127.0.0.1\r\n\t2015-07-27 12:24:36,708 DEBUG [cassandra.io.asyncorereactor][Dummy-6] Closing connection (4395133920) to 127.0.0.1\r\n\t2015-07-27 12:24:36,710 DEBUG [cassandra.io.asyncorereactor][Dummy-6] Closed socket to 127.0.0.1\r\n\t2015-07-27 12:24:36,715 ERROR [waitress][MainThread] Unexpected exception when flushing\r\n\tTraceback (most recent call last):\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 140, in handle_write\r\n\t    flush()\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 259, in _flush_some\r\n\t    outbuf.skip(num_sent, True)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 269, in skip\r\n\t    buf.skip(numbytes, allow_prune)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 77, in skip\r\n\t    numbytes, self.remain)\r\n\tValueError: Can't skip 4217 bytes in buffer of 0 bytes\r\n\t2015-07-27 12:24:36,779 ERROR [waitress][cassandra_driver_event_loop] Socket error\r\n\tTraceback (most recent call last):\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 167, in handle_read\r\n\t    data = self.recv(self.adj.recv_bytes)\r\n\t  File \"/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncore.py\", line 379, in recv\r\n\t    data = self.socket.recv(buffer_size)\r\n\tBlockingIOError: [Errno 35] Resource temporarily unavailable\r\n\t2015-07-27 12:24:37,079 ERROR [waitress][MainThread] Unexpected exception when flushing\r\n\tTraceback (most recent call last):\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 140, in handle_write\r\n\t    flush()\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 259, in _flush_some\r\n\t    outbuf.skip(num_sent, True)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 269, in skip\r\n\t    buf.skip(numbytes, allow_prune)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 77, in skip\r\n\t    numbytes, self.remain)\r\n\tValueError: Can't skip 251 bytes in buffer of 0 bytes\r\n\t2015-07-27 12:24:37,082 ERROR [waitress][MainThread] Unexpected exception when flushing\r\n\tTraceback (most recent call last):\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 140, in handle_write\r\n\t    flush()\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 259, in _flush_some\r\n\t    outbuf.skip(num_sent, True)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 269, in skip\r\n\t    buf.skip(numbytes, allow_prune)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 77, in skip\r\n\t    numbytes, self.remain)\r\n\tValueError: Can't skip 251 bytes in buffer of 0 bytes\r\n\t2015-07-27 12:24:37,171 ERROR [waitress][cassandra_driver_event_loop] Unexpected exception when flushing\r\n\tTraceback (most recent call last):\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 140, in handle_write\r\n\t    flush()\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 259, in _flush_some\r\n\t    outbuf.skip(num_sent, True)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 269, in skip\r\n\t    buf.skip(numbytes, allow_prune)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 77, in skip\r\n\t    numbytes, self.remain)\r\n\tValueError: Can't skip 251 bytes in buffer of 0 bytes\r\n\t2015-07-27 12:24:37,187 ERROR [waitress][cassandra_driver_event_loop] Unexpected exception when flushing\r\n\tTraceback (most recent call last):\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 140, in handle_write\r\n\t    flush()\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 259, in _flush_some\r\n\t    outbuf.skip(num_sent, True)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 269, in skip\r\n\t    buf.skip(numbytes, allow_prune)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 77, in skip\r\n\t    numbytes, self.remain)\r\n\tValueError: Can't skip 251 bytes in buffer of 0 bytes\r\n\t2015-07-27 12:24:37,284 ERROR [waitress][cassandra_driver_event_loop] Unexpected exception when flushing\r\n\tTraceback (most recent call last):\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 140, in handle_write\r\n\t    flush()\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 259, in _flush_some\r\n\t    outbuf.skip(num_sent, True)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 269, in skip\r\n\t    buf.skip(numbytes, allow_prune)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 77, in skip\r\n\t    numbytes, self.remain)\r\n\tValueError: Can't skip 182 bytes in buffer of 0 bytes\r\n\t2015-07-27 12:24:37,338 ERROR [waitress][MainThread] Unexpected exception when flushing\r\n\tTraceback (most recent call last):\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 140, in handle_write\r\n\t    flush()\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 259, in _flush_some\r\n\t    outbuf.skip(num_sent, True)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 269, in skip\r\n\t    buf.skip(numbytes, allow_prune)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 77, in skip\r\n\t    numbytes, self.remain)\r\n\tValueError: Can't skip 170 bytes in buffer of 0 bytes\r\n\t2015-07-27 12:24:38,293 DEBUG [cassandra.io.asyncorereactor][cassandra_driver_event_loop] Asyncore event loop ended\r\n\t2015-07-27 12:33:30,578 DEBUG [cassandra.cluster][Dummy-6] Connecting to cluster, contact points: ['127.0.0.1']; protocol version: 4\r\n\t2015-07-27 12:33:30,581 DEBUG [cassandra.pool][Dummy-6] Host 127.0.0.1 is now marked up\r\n\t2015-07-27 12:33:30,582 DEBUG [cassandra.cluster][Dummy-6] [control connection] Opening new connection to 127.0.0.1\r\n\t2015-07-27 12:33:30,584 DEBUG [cassandra.connection][Dummy-6] Not sending options message for new connection(4384605240) to 127.0.0.1 because compression is disabled and a cql version was not specified\r\n\t2015-07-27 12:33:30,585 DEBUG [cassandra.connection][Dummy-6] Sending StartupMessage on <AsyncoreConnection(4384605240) 127.0.0.1:9042>\r\n\t2015-07-27 12:33:30,586 DEBUG [cassandra.connection][Dummy-6] Sent StartupMessage on <AsyncoreConnection(4384605240) 127.0.0.1:9042>\r\n\t2015-07-27 12:33:30,587 DEBUG [cassandra.io.asyncorereactor][cassandra_driver_event_loop] Starting asyncore event loop\r\n\t2015-07-27 12:33:30,589 DEBUG [cassandra.connection][cassandra_driver_event_loop] Got ReadyMessage on new connection (4384605240) from 127.0.0.1\r\n\t2015-07-27 12:33:30,591 DEBUG [cassandra.cluster][Dummy-6] [control connection] Established new connection <AsyncoreConnection(4384605240) 127.0.0.1:9042>, registering watchers and refreshing schema and topology\r\n\t2015-07-27 12:33:30,611 DEBUG [cassandra.cluster][Dummy-6] [control connection] Refreshing node list and token map using preloaded results\r\n\t2015-07-27 12:33:30,612 INFO  [cassandra.policies][Dummy-6] Using datacenter 'datacenter1' for DCAwareRoundRobinPolicy (via host '127.0.0.1'); if incorrect, please specify a local_dc to the constructor, or limit contact points to local cluster nodes\r\n\t2015-07-27 12:33:30,613 DEBUG [cassandra.cluster][Dummy-6] [control connection] Finished fetching ring info\r\n\t2015-07-27 12:33:30,614 DEBUG [cassandra.cluster][Dummy-6] [control connection] Rebuilding token map due to topology changes\r\n\t2015-07-27 12:33:30,815 DEBUG [cassandra.cluster][Dummy-6] [control connection] Fetched schema, rebuilding metadata\r\n\t2015-07-27 12:33:30,910 DEBUG [cassandra.cluster][Dummy-6] Control connection created\r\n\t2015-07-27 12:33:30,912 DEBUG [cassandra.pool][Thread-11] Initializing connection for host 127.0.0.1\r\n\t2015-07-27 12:33:30,914 DEBUG [cassandra.connection][Thread-11] Not sending options message for new connection(4384961928) to 127.0.0.1 because compression is disabled and a cql version was not specified\r\n\t2015-07-27 12:33:30,915 DEBUG [cassandra.connection][Thread-11] Sending StartupMessage on <AsyncoreConnection(4384961928) 127.0.0.1:9042>\r\n\t2015-07-27 12:33:30,917 DEBUG [cassandra.connection][Thread-11] Sent StartupMessage on <AsyncoreConnection(4384961928) 127.0.0.1:9042>\r\n\t2015-07-27 12:33:30,918 DEBUG [cassandra.connection][cassandra_driver_event_loop] Got ReadyMessage on new connection (4384961928) from 127.0.0.1\r\n\t2015-07-27 12:33:30,920 DEBUG [cassandra.pool][Thread-11] Finished initializing connection for host 127.0.0.1\r\n\t2015-07-27 12:33:30,921 DEBUG [cassandra.cluster][Thread-11] Added pool for host 127.0.0.1 to session\r\n\t2015-07-27 12:33:30,954 DEBUG [cassandra.cluster][Dummy-6] Shutting down Cluster Scheduler\r\n\t2015-07-27 12:33:30,955 DEBUG [cassandra.cluster][Dummy-6] Shutting down control connection\r\n\t2015-07-27 12:33:30,956 DEBUG [cassandra.cluster][Task Scheduler] Not executing scheduled task due to Scheduler shutdown\r\n\t2015-07-27 12:33:30,957 DEBUG [cassandra.io.asyncorereactor][Dummy-6] Closing connection (4384605240) to 127.0.0.1\r\n\t2015-07-27 12:33:30,958 DEBUG [cassandra.io.asyncorereactor][Dummy-6] Closed socket to 127.0.0.1\r\n\t2015-07-27 12:33:30,960 DEBUG [cassandra.io.asyncorereactor][Dummy-6] Closing connection (4384961928) to 127.0.0.1\r\n\t2015-07-27 12:33:30,961 DEBUG [cassandra.io.asyncorereactor][Dummy-6] Closed socket to 127.0.0.1\r\n\t2015-07-27 12:33:30,966 ERROR [waitress][cassandra_driver_event_loop] Unexpected exception when flushing\r\n\tTraceback (most recent call last):\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 140, in handle_write\r\n\t    flush()\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/channel.py\", line 259, in _flush_some\r\n\t    outbuf.skip(num_sent, True)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 269, in skip\r\n\t    buf.skip(numbytes, allow_prune)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/buffers.py\", line 77, in skip\r\n\t    numbytes, self.remain)\r\n\tValueError: Can't skip 4217 bytes in buffer of 0 bytes\r\n\tTraceback (most recent call last):\r\n\t  File \"/Applications/PyCharm.app/helpers/pydev/pydevd.py\", line 1733, in <module>\r\n\t    debugger.run(setup['file'], None, None)\r\n\t  File \"/Applications/PyCharm.app/helpers/pydev/pydevd.py\", line 1226, in run\r\n\t    pydev_imports.execfile(file, globals, locals)  # execute the script\r\n\t  File \"/Applications/PyCharm.app/helpers/pydev/_pydev_execfile.py\", line 38, in execfile\r\n\t    exec(compile(contents+\"\\n\", file, 'exec'), glob, loc) #execute the script\r\n\t  File \"/Applications/PyCharm.app/helpers/pycharm/pycharm_load_entry_point.py\", line 8, in <module>\r\n\t    load_entry_point(dist, \"console_scripts\", name)()\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/pyramid/scripts/pserve.py\", line 58, in main\r\n\t    return command.run()\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/pyramid/scripts/pserve.py\", line 360, in run\r\n\t    serve()\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/pyramid/scripts/pserve.py\", line 339, in serve\r\n\t    server(app)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/paste/deploy/loadwsgi.py\", line 189, in server_wrapper\r\n\t    **context.local_conf)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/paste/deploy/util.py\", line 55, in fix_call\r\n\t    val = callable(*args, **kw)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/__init__.py\", line 21, in serve_paste\r\n\t    serve(app, **kw)\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/__init__.py\", line 18, in serve\r\n\t    server.run()\r\n\t  File \"/Users/usertest/Virtualenvs/app/lib/python3.4/site-packages/waitress-0.8.9-py3.4.egg/waitress/server.py\", line 154, in run\r\n\t    use_poll=self.adj.asyncore_use_poll,\r\n\t  File \"/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncore.py\", line 208, in loop\r\n\t    poll_fun(timeout, map)\r\n\t  File \"/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncore.py\", line 145, in poll\r\n\t    r, w, e = select.select(r, w, e, timeout)\r\n\tOSError: [Errno 9] Bad file descriptor\r\n\t2015-07-27 12:33:32,649 DEBUG [cassandra.io.asyncorereactor][cassandra_driver_event_loop] Asyncore event loop ended\r\n\t2015-07-27 12:34:27,489 DEBUG [cassandra.io.asyncorereactor][Dummy-12] Waiting for event loop thread to join...\r\n\t2015-07-27 12:34:27,489 DEBUG [cassandra.io.asyncorereactor][Dummy-12] Event loop thread was joined"},"comment":{"url":"https://api.github.com/repos/Pylons/waitress/issues/comments/125263069","html_url":"https://github.com/Pylons/waitress/issues/106#issuecomment-125263069","issue_url":"https://api.github.com/repos/Pylons/waitress/issues/106","id":125263069,"user":{"login":"tseaver","id":242750,"avatar_url":"https://avatars.githubusercontent.com/u/242750?v=3","gravatar_id":"","url":"https://api.github.com/users/tseaver","html_url":"https://github.com/tseaver","followers_url":"https://api.github.com/users/tseaver/followers","following_url":"https://api.github.com/users/tseaver/following{/other_user}","gists_url":"https://api.github.com/users/tseaver/gists{/gist_id}","starred_url":"https://api.github.com/users/tseaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tseaver/subscriptions","organizations_url":"https://api.github.com/users/tseaver/orgs","repos_url":"https://api.github.com/users/tseaver/repos","events_url":"https://api.github.com/users/tseaver/events{/privacy}","received_events_url":"https://api.github.com/users/tseaver/received_events","type":"User","site_admin":false},"created_at":"2015-07-27T16:24:27Z","updated_at":"2015-07-27T16:24:27Z","body":"I believe this is the same as #63, which is fixed on the trunk, which now uses a separate socket map from the global `asyncore.socket_map`.  Can you test your app with the `master` branch?"}}