umongo icon indicating copy to clipboard operation
umongo copied to clipboard

Adding support for Tornado motor async client

Open OneWithNoFace opened this issue 6 years ago • 5 comments

motor_tornado.py.txt

Changes made in umongo/frameworks/motor_asynio.py:

  1. Imported corresponding class (e.g, AsyncIOMotorDatabase -> MotorDatabase)
  2. 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.

tornado_test.py.txt

Is this way correct ??

OneWithNoFace avatar Jan 23 '19 07:01 OneWithNoFace

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 ?

touilleMan avatar Feb 11 '19 08:02 touilleMan

I have been running the AsyncIO Instance with Tornado for a couple months now on Production and it works fine. Am I missing something?

zikphil avatar May 20 '20 15:05 zikphil

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)?

lafrech avatar May 23 '20 23:05 lafrech

@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

touilleMan avatar May 24 '20 08:05 touilleMan

I'm happy to merge a PR doing this.

lafrech avatar May 24 '20 13:05 lafrech