FSX / momoko

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

momoko parameters lead to add timeout of tornado ioloop #130

Open ArrowZQ opened 8 years ago

ArrowZQ commented 8 years ago

when i set the auto_shrink of momoko.Pool() parameters equal to True, and send GET request to tornado server, this request don't do nothing.

@gen.coroutine
def get(self, *args, **kwargs):
        pass

but i foud out one request add one timeout of ioloop, and the callback of this timeout is None, the deadline of this timeout minus time.time() equal to 3595 or so. the max number of len(tornado.ioloop.IOLoop.instance()._timeouts)equal to 500 or so, don't continue to increase.

if i set the auto_shrink of momoko.Pool parameters equal to False, will not appear above the problem.

Looking forward to your reply.

haizaar commented 8 years ago

Can you post a complete example that illustrates the problem?

ArrowZQ commented 8 years ago

Here is momoko poll:

ioloop = tornado.ioloop.IOLoop.instance()
dbpool = momoko.Pool(
    dsn='dbname={dbname} user={user} password={pwd} host={host} port={port}',
    cursor_factory=psycopg2.extras.RealDictCursor,
    size=int(const.postgresql.get("size")),
    max_size=int(const.postgresql.get("max_size")),
    raise_connect_errors=True if const.postgresql.get("raise_connect_errors") == 'True' else False,
    reconnect_interval=int(const.postgresql.get("reconnect_interval")),
    auto_shrink=True,
    shrink_period=datetime.timedelta(seconds=1),
    shrink_delay=datetime.timedelta(minutes=5),
    ioloop=ioloop
)

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

here is request handler:

@gen.coroutine
def get(self, *args, **kwargs):
    pass

The following can be printed out timeout of ioloop

import time
io_loop = tornado.ioloop.IOLoop.instance()
for timeout in io_loop._timeouts:
    print timeout.callback
    print timeout.deadline - time.time()