I need help that why i am getting error like RecursionError
, i am using the python-socket
BTW before moving ahead i want to make it clear that this issue is not because of socket configuration it is working fine the simple test events work fine.
Here is my socket event that listen to specific event:
@sio_server.on(EVENT.REPLY_ON_TICKET)
async def reply_on_ticket_event(sid:str, data:dict):
sender_id = None
if data["sender_info"]["sender_id"]:
sender_id= data["sender_info"]["sender_id"]
else:
sender_id= data["sender_id"]
payload = {
"ticket_id": data["ticket_id"],
"sender_id": sender_id,
"notify": data["notify"],
"reply": data["reply"],
}
# Obtain a database session manually
db_session = next(get_db())
res = await reply_on_ticket_service(payload, db_session)
if res["success"]:
# the callback data for client socket
return {
"status_code": 200,
"success": True,
"message": "reply data",
"payload": res["data"],
}
return {"status_code": 400, "success": False}
and here the service that handle the reply tickets process:
async def reply_on_ticket_service(data:dict, db_session: Session = Depends(get_db)):
try:
new_reply= TicketReplyModal(reply_text=data["reply"],ticket_id=data["ticket_id"],sender_id=data["sender_id"])
new_reply_id= await db_manager.add_record(new_reply,db_session)
if not new_reply_id:
return {"success":False, 'status_code':400, "message":"Error occurred while creating new replay"}
new_record= await db_manager.get_record_by_id(new_reply_id, TicketReplyModal,db_session)
if not new_record:
return {"success":False, 'status_code':404, "message":"Unable to find record with newly created replay"}
sender_data = db_session.query(UserModel).filter(UserModel.id == new_record.sender_id).first()
if not sender_data:
return {"success":False, 'status_code':404, "message":"Unable to find sender info"}
reply = {
"id":new_record.id,
"created_at":new_record.created_at,
"reply_text":new_record.reply_text,
"ticket_id": new_record.ticket_id,
"sender":{
"id": sender_data.id,
"email": sender_data.email,
"profile_image": sender_data.profile_image,
"username": sender_data.username,
"public_key": sender_data.public_key,
}
}
return {"success": True, "data": reply}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
in reply_on_ticket_event
return method if i comment the line "payload": res["data"]
and then it works fine without any issue