New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restarting Postgress server during high load cases uncaught exception momoko #127

Closed
haizaar opened this Issue Oct 25, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@haizaar
Collaborator

haizaar commented Oct 25, 2015

This is the spin-off of #126. When running the following code and restarting the server in the middle, the following exception was raised:

ERROR:tornado.application:Exception in callback (6, <function null_wrapper at 0x7ff9431391b8>)
Traceback (most recent call last):
  File ".../local/lib/python2.7/site-packages/tornado/ioloop.py", line 866, in start
    handler_func(fd_obj, events)
  File ".../local/lib/python2.7/site-packages/tornado/stack_context.py", line 275, in null_wrapper
    return fn(*args, **kwargs)
  File ".../momoko/connection.py", line 713, in _io_callback
    self.ioloop.update_handler(self.fileno, IOLoop.WRITE)
  File ".../local/lib/python2.7/site-packages/tornado/ioloop.py", line 708, in update_handler
    self._impl.modify(fd, events | self.ERROR)
IOError: [Errno 2] No such file or directory

The code that reproduces the issue:

from tornado.ioloop import IOLoop
import momoko
from tornado.gen import engine


if __name__ == '__main__':

    ioloop = IOLoop.instance()
    db = momoko.Pool(
        dsn='dbname=your_db user=your_user password=very_secret_password '
            'host=remote_host port=5432',
        size=1,
        ioloop=ioloop,
    )

    future = db.connect()
    ioloop.add_future(future, lambda f: ioloop.stop())
    ioloop.start()
    future.result()

    @engine
    def never_ending_db_query_loop(callback):
        while True:
            try:
                cursor = yield db.execute('SELECT 1')
                row  = cursor.fetchone()
                print 'db returned: {0}'.format(row[0])
            except Exception as e:
                print e
        callback()


    never_ending_db_query_loop(ioloop.stop)
    ioloop.start()

@haizaar haizaar closed this in de98f2f Oct 26, 2015

haizaar added a commit that referenced this issue Oct 26, 2015

Merge pull request #128 from haizaar/master
Catching IOError. Fixes #127
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment