I was evaluating momoko for a project and noticed it was throwing errors if i instantiate the connection pool, trying to track this down i took the example from the momoko manual and that is also throwing the error,
$ cat test.py
from tornado import gen
from tornado.ioloop import IOLoop
from tornado.httpserver import HTTPServer
from tornado.options import parse_command_line
from tornado.web import *
import psycopg2
import momoko
class BaseHandler(RequestHandler):
@property
def db(self):
return self.application.db
class TutorialHandler(BaseHandler):
def get(self):
self.write('Some text here!')
self.finish()
if __name__ == '__main__':
parse_command_line()
application = Application([
(r'/', TutorialHandler)
], debug=True)
application.db = momoko.Pool(
dsn='dbname=your_db user=your_user password=very_secret_password '
'host=localhost port=5432',
size=1
)
http_server = HTTPServer(application)
http_server.listen(8888, 'localhost')
IOLoop.instance().start()
$ python -m test
[I 141119 14:42:04 connection:536] Opening new database connection
[E 141119 14:42:04 ioloop:585] Exception in callback (8, <function null_wrapper at 0x104b337d0>)
Traceback (most recent call last):
File "/Users/daniel/.venvs/foo/lib/python2.7/site-packages/tornado/ioloop.py", line 837, in start
handler_func(fd_obj, events)
File "/Users/daniel/.venvs/foo/lib/python2.7/site-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "/Users/daniel/.venvs/foo/lib/python2.7/site-packages/momoko/connection.py", line 599, in io_callback
self.ioloop.update_handler(self.fileno, IOLoop.WRITE)
File "/Users/daniel/.venvs/foo/lib/python2.7/site-packages/tornado/ioloop.py", line 681, in update_handler
self._impl.modify(fd, events | self.ERROR)
File "/Users/daniel/.venvs/foo/lib/python2.7/site-packages/tornado/platform/kqueue.py", line 45, in modify
self.unregister(fd)
File "/Users/daniel/.venvs/foo/lib/python2.7/site-packages/tornado/platform/kqueue.py", line 50, in unregister
self._control(fd, events, select.KQ_EV_DELETE)
File "/Users/daniel/.venvs/foo/lib/python2.7/site-packages/tornado/platform/kqueue.py", line 64, in _control
self._kqueue.control([kevent], 0)
OSError: [Errno 2] No such file or directory
^CTraceback (most recent call last):
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/daniel/foo/test.py", line 37, in <module>
IOLoop.instance().start()
File "/Users/daniel/.venvs/foo/lib/python2.7/site-packages/tornado/ioloop.py", line 812, in start
event_pairs = self._impl.poll(poll_timeout)
File "/Users/daniel/.venvs/foo/lib/python2.7/site-packages/tornado/platform/kqueue.py", line 67, in poll
kevents = self._kqueue.control(None, 1000, timeout)
KeyboardInterrupt
$ python --version
Python 2.7.3
$ pip freeze
Momoko==1.1.5
backports.ssl-match-hostname==3.4.0.2
brukva==0.0.1
certifi==14.05.14
geoip2==2.0.2
psycopg2==2.5.4
requests==2.4.3
tornado==4.0.2
wsgiref==0.1.2