chenjunkai 6 سال پیش
والد
کامیت
ef3f5ae841
3فایلهای تغییر یافته به همراه33 افزوده شده و 18 حذف شده
  1. 27 12
      Ansjer/test/util/spnsss.py
  2. 5 5
      Controller/Test.py
  3. 1 1
      Controller/UserManger.py

+ 27 - 12
Ansjer/test/util/spnsss.py

@@ -1,15 +1,30 @@
-import time
+#coding=utf-8
+import threading
+from time import sleep,ctime
 
+def sing():
+    for i in range(3):
+        print("正在唱歌...%d"%i)
+        sleep(1)
 
-# a+b+c=1000,且 a2+b2=c^2
-start_time = time.time()
-print(start_time)
-for a in range(0, 1001):
-    for b in range(0, 1001):
-        c = 1000-a-b
-        if a ** 2 + b ** 2 == c ** 2:
-            print("a,b,c:%d,%d,%d" % (a, b, c))
+def dance():
+    for i in range(3):
+        print("正在跳舞...%d"%i)
+        sleep(1)
 
-end_time = time.time()
-print("elapsed:%f" % (end_time-start_time))
-print("complete")
+if __name__ == '__main__':
+    print('---开始---:%s'%ctime())
+
+    t1 = threading.Thread(target=sing)
+    t2 = threading.Thread(target=dance)
+
+    t1.start()
+    t2.start()
+
+    while True:
+        length = len(threading.enumerate())
+        print('当前运行的线程数为:%d'%length)
+        if length<=1:
+            break
+
+        sleep(0.5)

+ 5 - 5
Controller/Test.py

@@ -44,13 +44,13 @@ class Test(View):
     animal_type_id=1:指定筛选条件
     '''
 
-    @method_decorator(csrf_exempt)
-    def dispatch(self, *args, **kwargs):
-        return super(Test, self).dispatch(*args, **kwargs)
+    # @method_decorator(csrf_exempt)
+    # def dispatch(self, *args, **kwargs):
+    #     return super(Test, self).dispatch(*args, **kwargs)
 
     def get(self, request, *args, **kwargs):
-        # response = ResponseObject()
-        # return response.json(474)
+        response = ResponseObject()
+        return response.json(474)
         return self.updatePrimaryMaster()
     # 增加
 

+ 1 - 1
Controller/UserManger.py

@@ -157,7 +157,7 @@ class perfectUserInfoView(TemplateView):
         except Exception as e:
             errorInfo = traceback.format_exc()
             print('修改设备信息错误: %s ' % errorInfo)
-            return response.json(116, repr(e))
+            return response.json(117, repr(e))
         else:
             res = CommonService.qs_to_dict(User)
             return response.json(0, res)