def send_request(thread_id):
while not stop_event.is_set():
try:
response = session.get("https://secret-share.net/play/", headers=headers, timeout=2) # Reduced timeout
print(f"Thread {thread_id}: {response.status_code}")
except requests.RequestException as e:
if stop_event.is_set():
print(f"Thread {thread_id}: Stopped")
else:
print(f"Thread {thread_id}: {e}")
def start_requests():
if threads and any(thread.is_alive() for thread in threads):
messagebox.showwarning("Warning", "Requests are already running.")
return
stop_event.clear()
for i in range(NUM_THREADS):
thread = threading.Thread(target=send_request, args=(i+1,), daemon=True)
threads.append(thread)
thread.start()
print("All threads started.")
def stop_requests():
stop_event.set()
session.close() # Close the session to terminate ongoing connections
for thread in threads:
if thread.is_alive():
thread.join(timeout=2) # Increased responsiveness with shorter join timeout
threads.clear() # Clean up the thread list once all threads are stopped
print("All threads stopped.")
def on_closing():
if messagebox.askokcancel("Quit", "Do you want to quit?"):
stop_requests()
root.destroy()
sys.exit()
Create the main window
root = tk.Tk()
root.title("Request Sender Control Panel")
root.geometry("300x150")
root.resizable(False, False)