代码优化
This commit is contained in:
parent
b888ca7943
commit
328311d723
3
main.py
3
main.py
|
|
@ -138,7 +138,8 @@ async def get_crawler_task(task_data: CrawlerItem, task_manager: Any = Depends(g
|
||||||
data = {"task_id": result["task_id"], "status": 4}
|
data = {"task_id": result["task_id"], "status": 4}
|
||||||
await task_manager.update_task_record(data)
|
await task_manager.update_task_record(data)
|
||||||
return {"code": 200, "message": "任务获取成功", "data": result}
|
return {"code": 200, "message": "任务获取成功", "data": result}
|
||||||
raise HTTPException(status_code=404, detail="队列暂时没有任务,请等待一段时间后重新尝试")
|
else:
|
||||||
|
return {"code": 200, "message": "暂时没有任务", "data": None}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"获取任务失败,失败原因: {e}")
|
print(f"获取任务失败,失败原因: {e}")
|
||||||
raise HTTPException(status_code=500, detail="获取任务失败;失败原因{}".format(e))
|
raise HTTPException(status_code=500, detail="获取任务失败;失败原因{}".format(e))
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,4 @@ redis_config:
|
||||||
host: 47.238.96.231
|
host: 47.238.96.231
|
||||||
port: 6379
|
port: 6379
|
||||||
password: QAhL5RXKh1o21RbEqRZb
|
password: QAhL5RXKh1o21RbEqRZb
|
||||||
db: 0
|
db: 1
|
||||||
|
|
@ -212,5 +212,5 @@ if __name__ == '__main__':
|
||||||
config = read_config(config_path)
|
config = read_config(config_path)
|
||||||
redis_conn = RedisTaskManager(config)
|
redis_conn = RedisTaskManager(config)
|
||||||
token = "opB4ztbdw45xFoJbXti20520bsEq3UDKKAtiDWHnGjjhP6v0KNFjqBM7bfzto6GLdUPviYnVdCgdCJYqe42nPoy6mvW59F3TPQZu"
|
token = "opB4ztbdw45xFoJbXti20520bsEq3UDKKAtiDWHnGjjhP6v0KNFjqBM7bfzto6GLdUPviYnVdCgdCJYqe42nPoy6mvW59F3TPQZu"
|
||||||
# redis_conn.write_string_to_h_set("user_token", token, 1)
|
redis_conn.write_string_to_h_set("user_token", token, 1)
|
||||||
print(redis_conn.check_field_exists("user_token", token))
|
# print(redis_conn.check_field_exists("user_token", token))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue