File size: 1,214 Bytes
dece3d8
5fa74cc
 
dece3d8
bc3aeb9
5fa74cc
d113efb
02e7b61
ec48066
e00660b
 
 
 
 
 
02e7b61
 
 
 
 
 
fa03655
 
 
e00660b
 
 
dece3d8
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr
import asyncio
import websockets
import threading

async def send_wss_request():
    uri = "wss://clone3-imagex-clone-advance.hf.space/queue/join"
    uri2 = "wss://clone3-imagex-clone-advance.hf.space/queue/join"

    while True:
        try:
            async with websockets.connect(uri) as websocket:
                # Receive the response
                response = await websocket.recv()
                print(f"Received: {response}")
            
            async with websockets.connect(uri2) as websocket:
                # Receive the response
                response = await websocket.recv()
                print(f"Received: {response}")

        except websockets.exceptions.ConnectionClosed:
            print("Connection closed. Reconnecting in 30 minutes.")
            
        # Sleep for 30 minutes before the next iteration
        await asyncio.sleep(30 * 60)

def run_websocket():
    asyncio.get_event_loop().run_until_complete(send_wss_request())

# Create a thread for the WebSocket function
websocket_thread = threading.Thread(target=run_websocket)
websocket_thread.start()

# Define your Gradio interface here
iface = gr.Interface(fn=None, live=True)
iface.launch()