time.clock()不推荐使用,改为time.time()
This commit is contained in:
parent
1c1f65caf2
commit
c7ecf2b7ec
|
@ -25,11 +25,11 @@ class DebugRequest:
|
||||||
|
|
||||||
def send(self):
|
def send(self):
|
||||||
# send request
|
# send request
|
||||||
_start_clock = time.clock()
|
_start_clock = time.time()
|
||||||
if self.project_variable:
|
if self.project_variable:
|
||||||
self.vars = Variable.get_project_variable(project_id=session.get('project_id'))
|
self.vars = Variable.get_project_variable(project_id=session.get('project_id'))
|
||||||
# recv response
|
# recv response
|
||||||
_end_clock = time.clock()
|
_end_clock = time.time()
|
||||||
self.elapsed_time = int((_end_clock - _start_clock) * 1000) + 1 # 执行过快导致结果耗时为0,这里特殊处理+1ms进行展示
|
self.elapsed_time = int((_end_clock - _start_clock) * 1000) + 1 # 执行过快导致结果耗时为0,这里特殊处理+1ms进行展示
|
||||||
self._handle_response()
|
self._handle_response()
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ class HTTPRequest:
|
||||||
|
|
||||||
def send(self) -> requests.Response:
|
def send(self) -> requests.Response:
|
||||||
# send request
|
# send request
|
||||||
_start_clock = time.clock()
|
_start_clock = time.time()
|
||||||
if self._method == 'get':
|
if self._method == 'get':
|
||||||
self.response = requests.get(url=self.url, **self.kwargs)
|
self.response = requests.get(url=self.url, **self.kwargs)
|
||||||
if self._method == 'post':
|
if self._method == 'post':
|
||||||
|
@ -89,7 +89,7 @@ class HTTPRequest:
|
||||||
if self._method == 'head':
|
if self._method == 'head':
|
||||||
self.response = requests.head(url=self.url, **self.kwargs)
|
self.response = requests.head(url=self.url, **self.kwargs)
|
||||||
# recv response
|
# recv response
|
||||||
_end_clock = time.clock()
|
_end_clock = time.time()
|
||||||
self.elapsed_time = int((_end_clock - _start_clock) * 1000) + 1
|
self.elapsed_time = int((_end_clock - _start_clock) * 1000) + 1
|
||||||
self._handle_response()
|
self._handle_response()
|
||||||
return self.response
|
return self.response
|
||||||
|
|
|
@ -43,13 +43,13 @@ class SQLRequest:
|
||||||
# 分割多行sql脚本
|
# 分割多行sql脚本
|
||||||
sql_list = self._sql_split(query=query)
|
sql_list = self._sql_split(query=query)
|
||||||
# send request
|
# send request
|
||||||
_start_clock = time.clock()
|
_start_clock = time.time()
|
||||||
with self as cursor:
|
with self as cursor:
|
||||||
for sql in sql_list:
|
for sql in sql_list:
|
||||||
self.affected_rows = cursor.execute(query=sql, args=args)
|
self.affected_rows = cursor.execute(query=sql, args=args)
|
||||||
self.all_rows = cursor.fetchall()
|
self.all_rows = cursor.fetchall()
|
||||||
# recv response
|
# recv response
|
||||||
_end_clock = time.clock()
|
_end_clock = time.time()
|
||||||
self.elapsed_time = int((_end_clock - _start_clock) * 1000) + 1
|
self.elapsed_time = int((_end_clock - _start_clock) * 1000) + 1
|
||||||
self._handle_response()
|
self._handle_response()
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,10 @@ class SSHRequest:
|
||||||
def send(self):
|
def send(self):
|
||||||
with self:
|
with self:
|
||||||
# send request
|
# send request
|
||||||
_start_clock = time.clock()
|
_start_clock = time.time()
|
||||||
stdin, stdout, stderr = self.exec_command()
|
stdin, stdout, stderr = self.exec_command()
|
||||||
# recv response
|
# recv response
|
||||||
_end_clock = time.clock()
|
_end_clock = time.time()
|
||||||
self.elapsed_time = int((_end_clock - _start_clock) * 1000) + 1
|
self.elapsed_time = int((_end_clock - _start_clock) * 1000) + 1
|
||||||
self.stdout = stdout.read().decode('utf-8')
|
self.stdout = stdout.read().decode('utf-8')
|
||||||
self.stderr = stderr.read().decode('utf-8')
|
self.stderr = stderr.read().decode('utf-8')
|
||||||
|
|
Loading…
Reference in New Issue