Python Twisted adbapi's runInteraction() with inlineCallbacks

def _insert_transaction(txn, some, vars):
    txn.execute('INSERT INTO [...]', [some, vars])
    return txn.execute('SELECT [...]').fetchone()

def insert_stuff(some, vars)
    stuff = yield db.runInteraction(insert_transaction, some, vars)
2016-07-27 14:28:32+0200 [_GenericHTTPChannelProtocol,0,] Unhandled Error writing response
    Traceback (most recent call last):
      File "/path/env/lib/python3.5/site-packages/twisted/web/", line 234, in render
        body = resrc.render(self)
      File "/path/env/lib/python3.5/site-packages/klein/", line 273, in render
        d.addCallback(write_response).addErrback(log.err, _why="Unhandled Error writing response")
      File "/path/env/lib/python3.5/site-packages/twisted/internet/", line 317, in addCallback
      File "/path/env/lib/python3.5/site-packages/twisted/internet/", line 306, in addCallbacks
    --- <exception caught here> ---
      File "/path/env/lib/python3.5/site-packages/twisted/internet/", line 587, in _runCallbacks
        current.result = callback(current.result, *args, **kw)
      File "/path/env/lib/python3.5/site-packages/klein/", line 209, in write_response
      File "/path/env/lib/python3.5/site-packages/twisted/web/", line 213, in write
        http.Request.write(self, data)
      File "/path/env/lib/python3.5/site-packages/twisted/web/", line 952, in write
        self.sentLength = self.sentLength + len(data)
    builtins.TypeError: object of type 'generator' has no len()

yield was the problem -> removing it solved the exception, but not the problem - no returns a deferred

Proudly powered by Microsoft IIS, Visual Basic .NET and DHTML. NOT.
Copyright © MKzero 2013
License Info