|
|
@@ -16,17 +16,15 @@ class Roll_Lanqiupipeline(object):
|
|
|
self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST)
|
|
|
self.db = self.mongo[M_DB]
|
|
|
|
|
|
- # @defer.inlineCallbacks
|
|
|
- # def process_item(self, item, spider):
|
|
|
- # out = defer.Deferred()
|
|
|
- # reactor.callInThread(self._do_calculation, item, out)
|
|
|
- # yield out
|
|
|
- # defer.returnValue(item)
|
|
|
- # # self._do_calculation(item)
|
|
|
- # # return
|
|
|
-
|
|
|
+ @defer.inlineCallbacks
|
|
|
def process_item(self, item, spider):
|
|
|
- # def _do_calculation(self, item, out):
|
|
|
+ out = defer.Deferred()
|
|
|
+ reactor.callInThread(self._do_calculation, item, out)
|
|
|
+ yield out
|
|
|
+ defer.returnValue(item)
|
|
|
+
|
|
|
+ # def process_item(self, item, spider):
|
|
|
+ def _do_calculation(self, item, out):
|
|
|
url = 'http://admin.5gogo.com'
|
|
|
roll_lq = []
|
|
|
# 使用twisted将mysql插入变成异步执行
|
|
|
@@ -323,4 +321,4 @@ class Roll_Lanqiupipeline(object):
|
|
|
else:
|
|
|
logger.warning('{},赛事结果状态接口异常提交失败, {}'.format('lq', res))
|
|
|
logger.warning(status_dict)
|
|
|
- # reactor.callFromThread(out.callback, item)
|
|
|
+ reactor.callFromThread(out.callback, item)
|