-
Type: Task
-
Resolution: Done
-
Priority: Minor - P4
-
None
-
Affects Version/s: 0.6.2
-
Component/s: tornado
-
None
-
Environment:Ubuntu 14.04
MongoDB 3.0.12
Python 3.5.2
Tornado 4.4.1
PyMongo 2.8
Hello. I have issue with many connection to database when I run Tornado coroutine asynchronously. I wrote simple example.
example.py
# coding=utf-8 import motor import tornado.gen import tornado.ioloop client = motor.motor_tornado.MotorClient() db = client['test'] @tornado.gen.coroutine def save(): yield db.test.insert({'key': 'value'}) client.close() # Nothing happened async def main(): print((await db.command('serverStatus'))['connections']['current']) # 1 save() print((await db.command('serverStatus'))['connections']['current']) # 2 if __name__ == '__main__': tornado.ioloop.IOLoop.instance().run_sync(main)
In my project many asynchronous inserts and connections count up to ~800. I have 30 instances of Tornado on different servers with connection to single MongoDB instance. Give me a feedback please.