async def check_task(self): while True: Logger.debug('[check] check task loop') try: await self.start_check() except Exception as e: await self.handle_task_exception(e) if Config.APP_ENV == Config.AppEnvType.TEST: break
async def check_low_score_task(self): while True: Logger.debug('[check] check low score task loop') try: await self.remove_low_score_ip() except Exception as e: await self.handle_task_exception(e) if Config.APP_ENV == Config.AppEnvType.TEST: break await asyncio.sleep(Config.DEFAULT_CHECK_CLEAN_IP_INTERVAL)
async def check_stats_task(self): while True: Logger.debug('[get] check stats task loop') try: await self.running_stats() except Exception as e: await self.handle_task_exception(e) if Config.APP_ENV == Config.AppEnvType.TEST: break await asyncio.sleep(Config.DEFAULT_STATS_CHECK_INTERVAL)
async def check_legacy_task(self): while True: Logger.debug('[get] check legacy task loop') try: await self.remove_legacy_ip() except Exception as e: await self.handle_task_exception(e) if Config.APP_ENV == Config.AppEnvType.TEST: break await asyncio.sleep(Config.DEFAULT_LEGACY_IP_CHECK_INTERVAL)
async def crawl_task(self): while True: Logger.debug('[get] crawl task loop') try: await self.start_crawl() except Exception as e: await self.handle_task_exception(e) if Config.APP_ENV == Config.AppEnvType.TEST: break await asyncio.sleep(Config.DEFAULT_LOOP_INTERVAL)
async def recheck_ip_task(self): key = 'recheck_ip' while True: Logger.debug('[check] recheck ip task loop') try: if not await Redis.last_time_check( key, Config.DEFAULT_CHECK_INTERVAL): await Redis.save_last_time(key) await self.resend_check_ip() except Exception as e: await self.handle_task_exception(e) if Config.APP_ENV == Config.AppEnvType.TEST: break await asyncio.sleep(Config.DEFAULT_CHECK_INTERVAL)
async def check_dump_task(self): from src.app.ip_saver import IPSaver key = 'dump_to_file' while True: Logger.debug('[get] dump task loop') try: if not await Redis.last_time_check( key, Config.DEFAULT_DUMP_IP_INTERVAL): await Redis.save_last_time(key) await IPSaver().dump_to_file() except Exception as e: await self.handle_task_exception(e) if Config.APP_ENV == Config.AppEnvType.TEST: break await asyncio.sleep(Config.DEFAULT_DUMP_IP_INTERVAL)