Jelajahi Sumber

计算推流接口耗时

chanjunkai 5 tahun lalu
induk
melakukan
cf6c555500
1 mengubah file dengan 10 tambahan dan 5 penghapusan
  1. 10 5
      controller/index.py

+ 10 - 5
controller/index.py

@@ -428,6 +428,7 @@ def testRunSendStop(request):
         print("back1----", back[1].decode())  # back是一个元祖,可以通过元祖取值的方式获取结果
         return JsonResponse({'msg': 'stop Stream', 'code': 0})
 
+from datetime import datetime
 def testRunStream(request):
     request.encoding = 'utf-8'
     if request.method == 'GET':
@@ -435,18 +436,22 @@ def testRunStream(request):
     UID=request_dict.get('UID', None)
     PWD=request_dict.get('PWD', None)
     MSG=request_dict.get('MSG', None)
+    time1=datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
     command = "./pushtool {UID} {PWD} {MSG} 1".format(UID=UID, PWD=PWD, MSG=MSG)
+    time2=datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
+
     print('command=>{command}'.format(command=command))
     try:
-        back = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE). \
-            communicate(timeout=10)
+        # back = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE). \
+        #     communicate(timeout=10)
+        print("时间:%s"%datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3])
     except Exception as e:
         return repr(e)
     else:
-        print("back0----", back[0].decode())  # 注意需要进行解码操作,默认输出的是字节
-        print("back1----", back[1].decode())  # back是一个元祖,可以通过元祖取值的方式获取结果
+        # print("back0----", back[0].decode())  # 注意需要进行解码操作,默认输出的是字节
+        # print("back1----", back[1].decode())  # back是一个元祖,可以通过元祖取值的方式获取结果
         #return str(back[0].decode()) + str(back[1].decode())
-        return JsonResponse({'msg': 'run Stream', 'code': 0})
+        return JsonResponse({'msg': 'star is time1,end is time2', 'code': 0})
 
 
 #测试是否正常接口