|
@@ -298,20 +298,13 @@ async def test(request: Request):
|
|
|
request_origin = "unknown"
|
|
|
content = {"message": "Hello World" + request_origin, "db": "disconnect!!!"}
|
|
|
headers = {'Access-Control-Allow-Origin': request_origin}
|
|
|
+ content["db"] = "is_closed: " + str(database.is_closed()) + " is_usable:" + str(database.is_connection_usable())
|
|
|
try:
|
|
|
- database.connect(reuse_if_open=True)
|
|
|
dt = CustomUser.select()
|
|
|
for item in dt:
|
|
|
- print(item.id)
|
|
|
- content["db"] = "connected"
|
|
|
- except OperationalError as e:
|
|
|
- if 'MySQL server has gone away' in str(e):
|
|
|
- content["db"] = "broke"
|
|
|
- database.close()
|
|
|
- database.connect()
|
|
|
- if database.is_connection_usable():
|
|
|
- content["db"] = "broke , reconnect"
|
|
|
- logging.info("reconnect database")
|
|
|
+ print(item.name)
|
|
|
+ except Exception as e:
|
|
|
+ logging.info(e)
|
|
|
return JSONResponse(content=content, headers=headers)
|
|
|
|
|
|
|