Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

311
Views
Do I need to close pymongo session?
conn_pf = pymongo.Connection(ip,27023,slaveOk=True)

The above allows me to close the session using conn_pf.close().

But:

conn_pfname = pymongo.Connection(ip,27023,slaveOk=True).__getattr__(resource+"_pfname").__getattr__("data")

doesn't allow me to close using conn_pfname.close. It says collection types does not have close method. Did I really open session in my second case?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No, you don't need to close PyMongo connections. Leave them open so that PyMongo's connection pooling gives you the most efficient performance:

http://api.mongodb.com/python/current/faq.html#how-does-connection-pooling-work-in-pymongo

Also, the old APIs like "Connection" and "slave_ok" were deleted from PyMongo years ago, please upgrade to the latest version for the most correct and efficient driver. Use MongoClient:

http://api.mongodb.com/python/current/tutorial.html

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!