Switch to Future based interface?
Closed this issue · 2 comments
I am really interested in this project, but I think the current implementation could be drastically simplified if you switched to Tornado's coroutine / Future system ( http://tornado.readthedocs.org/en/latest/guide/coroutines.html ) rather than the callback interface that is currently implemented. This would mean someone using Momoko could do:
@gen.coroutine
def foo():
result = yield connection.execute()
Instead of the current Connection class attaching a callback on operations, an IOStream would need to be implemented I think: http://tornado.readthedocs.org/en/latest/iostream.html .
Doing things this way means that standard exception handling works, which could simplify the current implementation significantly. I can take a look at implementing this at some point; just wanted to jot some ideas down while I had time.
Apparently I was thinking about that quite a while. Its a logical thing to do. But its a still low priority for me until Tornado start to deprecate their old interface.
But I'll be happy to review your pull requests.
Future
s interface has been merged to master. You are welcome to test.