From a55142f904219a7a6b90f331bf79ea003081c4aa Mon Sep 17 00:00:00 2001 From: RandomGitUser321 Date: Sun, 22 Sep 2024 04:59:10 -0400 Subject: [PATCH] Add ws.close() to the websocket examples (#5020) * add ws.close() to websocket examples * add and explain ws.close() in websocket examples --- script_examples/websockets_api_example.py | 2 +- script_examples/websockets_api_example_ws_images.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script_examples/websockets_api_example.py b/script_examples/websockets_api_example.py index 5e80aace..d696d2bb 100644 --- a/script_examples/websockets_api_example.py +++ b/script_examples/websockets_api_example.py @@ -154,7 +154,7 @@ prompt["3"]["inputs"]["seed"] = 5 ws = websocket.WebSocket() ws.connect("ws://{}/ws?clientId={}".format(server_address, client_id)) images = get_images(ws, prompt) - +ws.close() # for in case this example is used in an environment where it will be repeatedly called, like in a Gradio app. otherwise, you'll randomly receive connection timeouts #Commented out code to display the output images: # for node_id in images: diff --git a/script_examples/websockets_api_example_ws_images.py b/script_examples/websockets_api_example_ws_images.py index b37d9893..6508ecc9 100644 --- a/script_examples/websockets_api_example_ws_images.py +++ b/script_examples/websockets_api_example_ws_images.py @@ -147,7 +147,7 @@ prompt["3"]["inputs"]["seed"] = 5 ws = websocket.WebSocket() ws.connect("ws://{}/ws?clientId={}".format(server_address, client_id)) images = get_images(ws, prompt) - +ws.close() # for in case this example is used in an environment where it will be repeatedly called, like in a Gradio app. otherwise, you'll randomly receive connection timeouts #Commented out code to display the output images: # for node_id in images: