Kaynağa Gözat

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	main.py
#	model.py
22285461@qq.com 5 ay önce
ebeveyn
işleme
ef5c6db29b
2 değiştirilmiş dosya ile 43 ekleme ve 0 silme
  1. 12 0
      db_decorator.py
  2. 31 0
      test.py

+ 12 - 0
db_decorator.py

@@ -0,0 +1,12 @@
+
+
+# peewee db close 装饰器
+from model import ZaneTest
+
+
+def peewee_db_close(func):
+    async def wrapper():
+        # print(args)
+        ZaneTest._schema.database.close()
+        return await func()
+    return wrapper

+ 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()