首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >momoko异步连接失败

momoko异步连接失败
EN

Stack Overflow用户
提问于 2013-01-24 13:57:53
回答 1查看 1.7K关注 0票数 0

我使用tornadoweb + momoko来制作小型web应用程序。昨天,我测试了我的应用程序'Apache Branch',我得到了下面的错误:

代码语言:javascript
复制
ERROR:root:Cannot send error response after headers written
ERROR:root:Uncaught exception POST /url/is/here/ (127.0.0.1)
HTTPRequest(protocol='http', host='localhost:8888', method='POST', uri='/url/is/here/', version='HTTP/1.1', remote_ip='127.0.0.1', body='some_data_here', headers={'Content-Length': '96', 'Connection': 'close', 'Content-Type': 'application/x-www-form-urlencoded', 'Host': 'localhost:8888', 'Accept-Encoding': 'gzip'})
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/tornado/web.py", line 1021, in _stack_context_handle_exception
    raise_exc_info((type, value, traceback))
  File "/usr/lib/python2.7/site-packages/tornado/stack_context.py", line 259, in _nested
    yield vars
  File "/usr/lib/python2.7/site-packages/tornado/stack_context.py", line 229, in wrapped
    callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/momoko/pools.py", line 313, in _io_callback
    state = self._conn.poll()
OperationalError: asynchronous connection failed

此消息在我询问TestWay处理程序时显示,如下所示:

代码语言:javascript
复制
class TestWay(BaseHandler):

    @property
    def db(self):
        if not hasattr(self.application, 'db'):
            self.application.db = momoko.AsyncClient({
                'host': 'localhost',
                'database': 'database_name',
                'user': 'user_name',
                'password': 'password_here',
                'min_conn': 1,
                'max_conn': 5,
                'cleanup_timeout': 10
            })
        return self.application.db

    @web.asynchronous
    @gen.engine
    def post(self, *args, **kwargs):
        self.db.execute(
            "SELECT key FROM table WHERE id = %s AND deleted = false",
            (self.get_argument('id', 1),),
            callback = (yield gen.Callback('callback_name'))
        )

        cursor = yield gen.Wait('callback_name')

        if cursor is not None:
            result = cursor.fetchall()
            if len(result) != 0 and len(result[0]) != 0:
                response = result[0][0]
        else:
            response = u'some message'
        self.write(response)
        self.finish()

我使用了这个http://momoko.61924.nl/examples.html中的文档

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-07 15:01:15

这是因为莫莫科试图在postgresql.conf中打开比max_connection更多的连接

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14494885

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档