txmongo: txmongo not working with azure cosmos db

I have a piece of code that works with pymongo and my cosmos DB uri:

from pymongo import MongoClient

mongodb_uri = 'mongodb://....'
client = MongoClient(mongodb_uri)

db = client.foo
collection = db.test
doc = collection.find_one()
print(doc)

However when I try the same with txmongo:

from txmongo.connection import ConnectionPool
from twisted.internet import defer, reactor

@defer.inlineCallbacks
def example():
    mongodb_uri = "mongodb://..."
    client = ConnectionPool(mongodb_uri)

    db = client.foo  
    test = db.test  
    doc = yield test.find_one()
    print(doc)

if __name__ == '__main__':
    example().addCallback(lambda ign: reactor.stop())
    reactor.run()

If the uri is mongodb://localhost:27017 all good but with the cosmos db uri it doesn’t work and I get an error message: TxMongo: run time of 1.0s exceeded. (Edit: removed the useless yield of the ConnectionPool call)

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 19 (10 by maintainers)

Most upvoted comments

Great!

@psi29a Bret, it would be cool if you could find time to review changes from #262 😃