FSX / momoko

Wraps (asynchronous) Psycopg2 for Tornado.
http://momoko.61924.nl/
Other
363 stars 73 forks source link

Switch to Future based interface? #94

Closed davidblewett closed 9 years ago

davidblewett commented 9 years ago

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.

haizaar commented 9 years ago

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.

haizaar commented 9 years ago

Futures interface has been merged to master. You are welcome to test.