It does not have to be in a for loop, but how would you process the data, put the list of data into an animated asynchronous "sleep". Essentially, I would like to do something like this that clearly doesn't work. It goes right through the loop without sleep. Should deferLater be used only for a method? If so, how could I achieve the same results by twisting, so there is a βdreamβ between each record to save the database?
@defer.inlineCallbacks def queryDatabase(self, kwargs): #Just testing deferLater for x in xrange(10000): yield txmongo.my_db.test_collection.save({"something":x * time.time()},safe=True) d = deferLater(reactor, 5, lambda: none) print str(datetime.datetime.now()) + ' ==> ' + str(x)
source share