Skip to content

txmongo not working with azure cosmos db #261

Description

@JoaquinKeller

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions