Closed harshathulasi closed 7 years ago
Sorry, all examples in examples/deferreds/
seem to be broken :(
examples/deferreds/insert.py
defines getConnection()
to return MongoConnectionPool()
, but then uses it like it is Deferred
:
def getConnection():
print "getting connection..."
return txmongo.MongoConnectionPool()
. . .
def example():
d = getConnection()
d.addErrback(log.err)
d.addCallback(getDatabase, "foo")
It can be fixed for example by replacing return txmongo.MongoConnectionPool()
with return defer.succeed(txmongo.MongoConnectionPool())
.
I will file a new issue about this with more specific title.
Actually, this particular example is bad anyway, please don't follow it :( It overuses deferreds for naturally synchronous tasks only to confuse things. deferreds/insert-consice.py
is a bit better, but suffers from same problems too.
Please look at inlinecallbacks
examples, they are much better (while not without problems, though).
Closing this in favor of #216
When trying to execute the "txmongo/examples/deferreds/insert.py" script, script fails with the following message:
Not sure if this code is compatible with python3 or some version mismatch: