Best practice combining django + PyMongo?

I have a call db = pymongo.Connection()in Django views.py for a simple MongoDB connection to store some simple statistics.

What is the best practice to get it to automatically support join join MongoDB?

Where do I need to put the code end_request()?

How to select an option max_pool_sizeduring a connection?

+5
source share
1 answer

How does pooling work in PyMongo?

Each instance of Connection has a built-in connection pool. By default, each thread receives its own socket, reserved during its first operation. Those sockets remain until end_request () is called by this thread.

end_request() , . , PyMongo .

, , auto_start_request = False, () .

, , , . end_request , . , , .

, , auto_start_request=False , .

, . , , , , . . , .

+7

All Articles