cxhy преди 6 месеца
родител
ревизия
8a5df7514a
променени са 1 файла, в които са добавени 31 реда и са изтрити 0 реда
  1. 31 0
      test.py

+ 31 - 0
test.py

@@ -0,0 +1,31 @@
+
+import time
+import requests
+
+import threading
+
+
+def http_get(url):
+    response = requests.get(url)
+    resp = response.text
+    print(f"Response: {len(resp)}")
+
+
+def test():
+    print('This is a test function in test.py')
+
+    url = "https://yixue.cxhy.cn/api/test2"
+
+    while True:
+        for i in range(100):
+            t = threading.Thread(target=http_get, args=(url,))
+            t.setDaemon(True)
+            t.start()
+            print(f"Thread {i} started")
+            # r = http_get(url)
+            # print(len(r))
+        time.sleep(3)
+
+
+if __name__ == '__main__':
+    test()