umongo
umongo copied to clipboard
Adding support for Tornado motor async client
Changes made in umongo/frameworks/motor_asynio.py:
- Imported corresponding class (e.g, AsyncIOMotorDatabase -> MotorDatabase)
- Changed class names accordingly.
The idea behind doing it this is: As far as I can understand motor has a core set of classes, the classes specific to the framework (i.e, Asyncio and Tornado) are just wrapped around the core class. eg. AsyncIOMotorDatabase and MotorDatabase wrap AgnosticDatabase So I thought that changing the import according to the motor tornado would work. I tried by creating a simple tornado application and it does work for the creating a Document instance and committing it.
Is this way correct ??
Hi,
So I thought that changing the import according to the motor tornado would work. I tried by creating a simple tornado application and it does work for the creating a Document instance and committing it.
Yes, that's my idea also. Beside if you have also converted the framework tests and everything is passing I guess you have something worth merging ;-)
Can you open a PR with this code please ?
I have been running the AsyncIO Instance with Tornado for a couple months now on Production and it works fine. Am I missing something?
I have no time (and interest) for this right now.
Did you check the diff between AsyncIO (in the code) and Tornado (in your PR)?
@zikphil If I recall well, Tornado is now compatible with the asyncio event loop. This used to be not the case (for instance the motor driver provides 2 different backends for asyncio and for Tornardo) So it's very possible Tornado is now supported out of the box by just supporting asyncio \o/ (if that's the case it would be good to update the document and the README)
I guess it would be still interesting to add a new test_motor_tornado.py
which would be heavily based on https://github.com/Scille/umongo/blob/master/tests/frameworks/test_motor_asyncio.py (basically just start a tornado event loop instead of an asyncio one) to make sure there is no cornercases
I'm happy to merge a PR doing this.