cxhy 4 months ago
parent
commit
8a5df7514a
1 changed files with 31 additions and 0 deletions
  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()