提问人:Nam Anh 提问时间:11/17/2023 最后编辑:Nam Anh 更新时间:11/17/2023 访问量:23
如果使用 Flask 应用运行 gRPC 服务器,则无法查看 gRPC 函数中的日志
Cannot see log from gRPC functions if run gRPC server with Flask app
问:
我正在构建一个带有 gRPC 服务器的微服务,该服务器在同一个 python 文件中有一个 Flask 应用程序。.测试时,我可以成功接收来自 gRPC 函数的响应。但是我看不到来自 gRPC 函数的任何日志。这是我使用 Flask 应用程序启动服务器时的代码(我什至在 gRPC 函数中使用了 print())
def run_grpc_server():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
post_service_pb2_grpc.add_PostServiceServicer_to_server(PostService(), server)
server.add_insecure_port('[::]:50054')
server.start()
server.wait_for_termination()
if __name__ == '__main__':
grpc_thread = threading.Thread(target=run_grpc_server)
grpc_thread.start()
try:
app.run(debug=True, port=POST_PORT)
except KeyboardInterrupt:
grpc_thread.join() # Wait for the gRPC thread to finish
我正在从运行“python3 post_service_server.py”的窗口中检查日志,这就是我所能看到的
python3 post_service_server.py
* Serving Flask app 'post_service_server'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:50056
Press CTRL+C to quit
* Restarting with stat
* Debugger is active!
* Debugger PIN: 444-907-812
有人可以帮忙查看 gRPC 函数的调试日志或将我指向跟踪它们的确切位置吗?非常感谢
答: 暂无答案
评论