FSX / momoko

Wraps (asynchronous) Psycopg2 for Tornado.
http://momoko.61924.nl/
Other
360 stars 73 forks source link

Asynchronous connection failed when several users test site #40

Closed rusfearuth closed 11 years ago

rusfearuth commented 11 years ago

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

more details here http://stackoverflow.com/questions/14494885/asynchronous-connection-failed-by-momoko

FSX commented 11 years ago

There's not enough information for me to say what could be wrong. I only see that no connection can be made. Are you sure your PostgreSQL server is running and that the database host, post, username and password are correct?

rusfearuth commented 11 years ago

Okay, Here is some information about database server:

Web server (x86_64)

rusfearuth commented 11 years ago

Hmm... I see on interesting thing... When I use on single-process server, I won't get this error


server = HTTPServer(app, on_keep_alive=True, xheaders=True)
server.bind(8888)
server.start()
IOLoop.instance().start()

...
or
...

server = HTTPServer(app, on_keep_alive=True, xheaders=True)
server.listing(8888)
IOLoop.instance().start()

When I use multi-process server, I will get this message.

I hope that will help you

FSX commented 11 years ago

Thanks. Going to see if I can find a solution.

On Thu, Jan 24, 2013 at 4:01 PM, Alexander notifications@github.com wrote:

Hmm... I see on interesting thing... When I use on single-process server, I won't get this error

server = HTTPServer(app, on_keep_alive=True, xheaders=True)server.bind(8888)server.start()IOLoop.instance().start() ...or... server = HTTPServer(app, on_keep_alive=True, xheaders=True)server.listing(8888)IOLoop.instance().start()

When I use multi-process server, I will get this message.

I hope that will help you

— Reply to this email directly or view it on GitHubhttps://github.com/FSX/momoko/issues/40#issuecomment-12654743.

rusfearuth commented 11 years ago

NP. You're welcome. I'm realy interested in your solution =)

FSX commented 11 years ago

Everything seems to be working here. Even when I let the HTTP server spawn multiple processes.

rusfearuth commented 11 years ago

I analyzed configs postgresql and find that max_connection was overloaded when I runned tornado in multi-processing mode. After, I increased max connection number problem has gone.

Sorry...

FSX commented 11 years ago

Hmm, ok. There should be a proper warning when this happens. I'll take that in account for 1.0.0. Thanks!

rusfearuth commented 11 years ago

You're welcome. I look forward for a new version =) Thanks for work =)