Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

momoko parameters lead to add timeout of tornado ioloop #130

Open
ArrowZQ opened this issue Oct 27, 2015 · 2 comments
Open

momoko parameters lead to add timeout of tornado ioloop #130

ArrowZQ opened this issue Oct 27, 2015 · 2 comments

Comments

@ArrowZQ
Copy link

ArrowZQ commented Oct 27, 2015

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
Copy link
Collaborator

haizaar commented Oct 27, 2015

Can you post a complete example that illustrates the problem?

@ArrowZQ
Copy link
Author

ArrowZQ commented Oct 28, 2015

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()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants