I’m trying to do some benchmarking of Twisted & Tornado with Mongodb.
I have Twisted and Tornado running with PyMongo (I know this is not async – I am just curious)
I have Tornado running with Asyncmongo.
I can not get Twisted running with Asyncmongo.
As an experiment I wrote some simple code to test asyncmongo and the callback is never called. So now I am wondering is asyncmongo tied into Tornado?
import asyncmongo
def main():
db = asyncmongo.Client(pool_id='mydb', host='localhost', port=27017, maxcached=10, maxconnections=10, dbname='mydb')
db.houses.find({'price':25, }, callback=_on_response )
print "query done"
while True:
pass
def _on_response(self, response, error):
print "yay - response"
if __name__ == '__main__':
main()
“yay – response” – Is never displayed – the callback is not activated.
Is it possible to make the callback fire if you do not use any frameworks? Is it possible to make the callback fire using Twisted’s reactor / deferreds? If not how do people usually get Twisted talking to Mongo?
Try https://github.com/fiorix/mongo-async-python-driver