AB
Size: a a a
AB
EB
AB
AB
AB
AB
AB
EB
AR
AR
EB
AR
AR
AR
AR
AR
AR
AR
AB
class UsingBlocking(object):
@defer.inlineCallbacks
def process_item(self, item, spider):
price = item["price"][0]
out = defer.Deferred()
reactor.callInThread(self._do_calculation, price, out)
item["price"][0] = yield out
defer.returnValue(item)
def _do_calculation(self, price, out):
new_price = price + 1
time.sleep(0.10)
reactor.callFromThread(out.callback, new_price)
AR