shadowshell 0.0.34__tar.gz → 0.0.36__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowshell
3
- Version: 0.0.34
3
+ Version: 0.0.36
4
4
  Summary: www.shadowshell.xyz
5
5
  Author-email: shadowshell <shadowshellxyz@foxmail.com>
6
6
  License: MIT
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "shadowshell" # 全局唯一名称(检查PyPI是否被占用)
7
7
  #version = "0.0.24" # 版本号(每次更新需递增)
8
- version = "0.0.34" # 版本号(每次更新需递增)
8
+ version = "0.0.36" # 版本号(每次更新需递增)
9
9
  authors = [{ name = "shadowshell", email = "shadowshellxyz@foxmail.com" }]
10
10
  description = "www.shadowshell.xyz"
11
11
  readme = "README.md"
@@ -72,19 +72,28 @@ class TestTemplate:
72
72
  self.logger.debug('Nothing')
73
73
  return
74
74
 
75
- def performance_monitor(func):
76
- def wrapper(*args, **kwargs):
77
- start = time.perf_counter()
78
- result = func(*args, **kwargs)
79
- elapsed = time.perf_counter() - start
80
- logger.info(f"[PERFORMANCE_MONITOR][{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
81
- return result
82
- return wrapper
83
-
84
- def function_monitor(clazz=None):
75
+ def performance_monitor(class_name=None):
85
76
  def decorator(func):
86
77
  def wrapper(*args, **kwargs):
87
78
  start = time.perf_counter()
79
+ result = None
80
+ try:
81
+ result = func(*args, **kwargs)
82
+ finally:
83
+ elapsed = time.perf_counter() - start
84
+ if (class_name is not None):
85
+ logger.info(f"[PERFORMANCE_MONITOR][{class_name}][{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
86
+ else:
87
+ logger.info(f"[PERFORMANCE_MONITOR][{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
88
+ return result
89
+ return wrapper
90
+ return decorator
91
+
92
+ def function_monitor(class_name=None):
93
+ def decorator(func):
94
+ def wrapper(*args, **kwargs):
95
+ start = time.perf_counter()
96
+ result = None
88
97
  try:
89
98
  result = func(*args, **kwargs)
90
99
  except Exception as e:
@@ -93,8 +102,8 @@ def function_monitor(clazz=None):
93
102
  logger.error(sys.exc_info()[0])
94
103
  finally:
95
104
  elapsed = time.perf_counter() - start
96
- if (clazz is not None):
97
- logger.info(f"[FUNCTION_MONITOR][{clazz.__name__}][{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
105
+ if (class_name is not None):
106
+ logger.info(f"[FUNCTION_MONITOR][{class_name}][{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
98
107
  else:
99
108
  logger.info(f"[FUNCTION_MONITOR][{func.__name__}] has ran, time elapsed:{elapsed:.6f}s.")
100
109
  return result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shadowshell
3
- Version: 0.0.34
3
+ Version: 0.0.36
4
4
  Summary: www.shadowshell.xyz
5
5
  Author-email: shadowshell <shadowshellxyz@foxmail.com>
6
6
  License: MIT
File without changes
File without changes