我收到一个错误“[Errno 5] Input/output error”,而 运行 一个 api on django

i am gettin an error "[Errno 5] Input/output error" while running an api on django

Django API代码:

def post(self,request)-> JsonResponse:
        try:
            self.email = request.data['email']
            self.mobile = request.data['mobile']
            self.password = request.data['password']
        except Exception as e:
            return JsonResponse(create_failure('400',f"invalid payload {e}","fail"))
        try:
            res = {}
            jwt_token = ''
            if self.email:
                password = Customer.objects.get(email=self.email).password
                username  = Customer.objects.get(email=self.email).username
                print(password)
                if check_password(self.password,password) :
                    jwt_token = make_jwt_token({'username':username})
                else:
                    return JsonResponse(create_failure('500',f"Invalid password","fail"))
            elif self.mobile:
                password = Customer.objects.get(mobile=self.mobile).password
                username  = Customer.objects.get(mobile=self.mobile).username
                if check_password( password,self.password) :
                    jwt_token = make_jwt_token({'username':username})
                else:
                    return JsonResponse(create_failure('500',f"Invalid password","fail"))
            res['token'] = jwt_token
        except Exception as e:
            return JsonResponse(create_failure('400',f"error in verifying the password {e}","fail"))
        return JsonResponse(create_success('User Verified',res))

邮递员 运行 时出错

{
    "StatusCode": "400",
    "Message": "error in verifying the password [Errno 5] Input/output error",
    "ReplyCode": "fail",
    "Data": []
}

上面的代码在本地机器上运行良好,但是当我将它部署到服务器时却出现了这个错误。我正在使用 cpanel 进行托管,它使用 CentOS

已解决我只需要从代码中删除打印。

如果您的服务器无处放置打印语句,则可能会发生这种情况。

例如,我是 运行 一个终端 window 的服务器,然后 window 以某种方式关闭但服务器仍然是 运行。根据您的情况,有 2 个选项:

  1. 终止进程。启动新服务器:sudo kill -9 $(sudo lsof -t -i:8000)。 (或搜索“查找端口并终止进程 [YOUR_OS]”以查找 OS-specific 信息。More details

  2. 管道你的命令输出:python MY_SCRIPT.py >/dev/null More details