Python Twisted adbapi's runInteraction() with inlineCallbacks

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

@inlineCallbacks
def insert_stuff(some, vars)
    [...]
    stuff = yield db.runInteraction(insert_transaction, some, vars)
    [...]
2016-07-27 14:28:32+0200 [_GenericHTTPChannelProtocol,0,127.0.0.1] Unhandled Error writing response
    Traceback (most recent call last):
      File "/path/env/lib/python3.5/site-packages/twisted/web/server.py", line 234, in render
        body = resrc.render(self)
      File "/path/env/lib/python3.5/site-packages/klein/resource.py", 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/defer.py", line 317, in addCallback
        callbackKeywords=kw)
      File "/path/env/lib/python3.5/site-packages/twisted/internet/defer.py", line 306, in addCallbacks
        self._runCallbacks()
    --- <exception caught here> ---
      File "/path/env/lib/python3.5/site-packages/twisted/internet/defer.py", line 587, in _runCallbacks
        current.result = callback(current.result, *args, **kw)
      File "/path/env/lib/python3.5/site-packages/klein/resource.py", line 209, in write_response
        request.write(r)
      File "/path/env/lib/python3.5/site-packages/twisted/web/server.py", line 213, in write
        http.Request.write(self, data)
      File "/path/env/lib/python3.5/site-packages/twisted/web/http.py", 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