コード例 #1
0
 async def _get_new_z8_obj(self, index):
     if index % 10 == 0:  # 不能共享一个对象了, 否则驱动访问会异常!
         try:
             del self.zhe_800_spike
         except:
             pass
         collect()
         self.zhe_800_spike = Zhe800Spike()
コード例 #2
0
    async def _update_db(self):
        '''
        秒杀数据实时更新
        :return:
        '''
        while True:
            self.lg = await self._get_new_logger(logger_name=get_uuid1())
            result = await self._get_db_old_data()
            if result is None:
                pass
            else:
                self.goods_index = 1
                tasks_params_list = TasksParamsListObj(
                    tasks_params_list=result, step=self.concurrency)
                self.zhe_800_spike = Zhe800Spike()
                index = 1
                while True:
                    try:
                        slice_params_list = tasks_params_list.__next__()
                        # self.lg.info(str(slice_params_list))
                    except AssertionError:  # 全部提取完毕, 正常退出
                        break

                    tasks = []
                    for item in slice_params_list:
                        self.lg.info('创建 task goods_id: {}'.format(item[0]))
                        tasks.append(
                            self.loop.create_task(
                                self._update_one_goods_info(item=item,
                                                            index=index)))
                        index += 1

                    await _get_async_task_result(tasks=tasks, logger=self.lg)

                self.lg.info('全部数据更新完毕'.center(100, '#'))
            if get_shanghai_time().hour == 0:  # 0点以后不更新
                await async_sleep(60 * 60 * 5.5)
            else:
                await async_sleep(2.5 * 60)

            try:
                del self.zhe_800_spike
            except:
                pass
            collect()
コード例 #3
0
 def __init__(self):
     self._set_headers()
     self.delete_sql_str = r'delete from dbo.zhe_800_xianshimiaosha where goods_id=%s'
     self.zhe_800_spike = Zhe800Spike()
コード例 #4
0
 def __init__(self):
     self._set_headers()
     self.delete_sql_str = z8_delete_str_3
     self.zhe_800_spike = Zhe800Spike()
     self._set_logger()