-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathViewers.py
More file actions
39 lines (30 loc) · 858 Bytes
/
Copy pathViewers.py
File metadata and controls
39 lines (30 loc) · 858 Bytes
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
38
39
import requests
import threading
import time
URL = input('Enter the URL: ')
REQUESTS_PER_SECOND = int(input('Enter the amount of Threads: '))
total_requests = 0
def make_requests():
global total_requests
while True:
requests.get(URL)
total_requests += 1
time.sleep(1 / REQUESTS_PER_SECOND)
def print_progress():
print(" ")
while True:
print(f"Total successful requests made: {total_requests}")
time.sleep(1)
def main():
threads = []
for _ in range(REQUESTS_PER_SECOND):
thread = threading.Thread(target=make_requests)
threads.append(thread)
thread.start()
progress_thread = threading.Thread(target=print_progress)
progress_thread.start()
for thread in threads:
thread.join()
progress_thread.join()
if __name__ == "__main__":
main()