Skip to content

Commit

Permalink
Add ws.close() to the websocket examples (comfyanonymous#5020)
Browse files Browse the repository at this point in the history
* add ws.close() to websocket examples

* add and explain ws.close() in websocket examples
  • Loading branch information
RandomGitUser321 authored Sep 22, 2024
1 parent 5718ef6 commit a55142f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion script_examples/websockets_api_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def get_images(ws, prompt):
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:
Expand Down
2 changes: 1 addition & 1 deletion script_examples/websockets_api_example_ws_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_images(ws, prompt):
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:
Expand Down

0 comments on commit a55142f

Please sign in to comment.