toolkits 0.2.8__py3-none-any.whl → 0.2.9__py3-none-any.whl
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.
- toolkits/system/shell_helper.py +17 -1
- {toolkits-0.2.8.dist-info → toolkits-0.2.9.dist-info}/METADATA +1 -1
- {toolkits-0.2.8.dist-info → toolkits-0.2.9.dist-info}/RECORD +5 -5
- {toolkits-0.2.8.dist-info → toolkits-0.2.9.dist-info}/WHEEL +1 -1
- {toolkits-0.2.8.dist-info → toolkits-0.2.9.dist-info}/entry_points.txt +0 -0
toolkits/system/shell_helper.py
CHANGED
@@ -150,6 +150,21 @@ async def run_command_async(command, timeout=5, encoding="utf-8", shell=False, c
|
|
150
150
|
return ret
|
151
151
|
|
152
152
|
|
153
|
+
def get_loop_obj():
|
154
|
+
try:
|
155
|
+
# 尝试获取当前线程的事件循环(可能会失败)
|
156
|
+
loop = asyncio.get_event_loop()
|
157
|
+
except RuntimeError as e:
|
158
|
+
# 如果报错 "There is no current event loop...",则创建新的事件循环
|
159
|
+
if "There is no current event loop" in str(e):
|
160
|
+
loop = asyncio.new_event_loop()
|
161
|
+
asyncio.set_event_loop(loop)
|
162
|
+
else:
|
163
|
+
# 其他 RuntimeError 直接抛出
|
164
|
+
raise
|
165
|
+
return loop
|
166
|
+
|
167
|
+
|
153
168
|
def exec_shell_async(command, timeout=60 * 10, encoding="utf-8", cwd=None, env=None):
|
154
169
|
"""
|
155
170
|
异常执行命令,检测执行时间超时
|
@@ -169,7 +184,8 @@ def exec_shell_async(command, timeout=60 * 10, encoding="utf-8", cwd=None, env=N
|
|
169
184
|
}
|
170
185
|
return ret
|
171
186
|
|
172
|
-
|
187
|
+
# asyncio.get_event_loop()
|
188
|
+
loop = get_loop_obj()
|
173
189
|
return loop.run_until_complete(run_command_async(command, timeout=timeout, encoding=encoding, cwd=cwd, env=env))
|
174
190
|
|
175
191
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
toolkits-0.2.
|
2
|
-
toolkits-0.2.
|
3
|
-
toolkits-0.2.
|
1
|
+
toolkits-0.2.9.dist-info/METADATA,sha256=hOzP91GG1CrzEbDHiUrLcpF9Q7DmxZEUearWc5tPghU,1157
|
2
|
+
toolkits-0.2.9.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
|
3
|
+
toolkits-0.2.9.dist-info/entry_points.txt,sha256=ioUpExuekI3N4XaBZ8NKV1mx0DZnKWLkg2PoGICq6OY,72
|
4
4
|
toolkits/3des/3des.py,sha256=DWfAUGtU7U74GrpnIgA8ZEw7R-kKWyKGfv3Ycqachlw,3400
|
5
5
|
toolkits/3des/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
toolkits/__init__.py,sha256=CBKKalWuRi-mXuf2iwrAI5zzzGcUU5e8xhQNgqBERmg,50
|
@@ -42,7 +42,7 @@ toolkits/system/load_module.py,sha256=UXNfE9drsfz9oOBq9EGdV4gjmiIYlJQECIt3PFaLxw
|
|
42
42
|
toolkits/system/priority_tasks.py,sha256=eUtKQatAnYcV3f3V3XY4FQ0u3afX8NHuqiBRcuv0d0I,7632
|
43
43
|
toolkits/system/process_monitor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
44
44
|
toolkits/system/process_monitor/process_monitor.py,sha256=_tXmWSOzAqAlHeGiBPrMGFU1Wjdr4zUAKNSPucqGRO8,12887
|
45
|
-
toolkits/system/shell_helper.py,sha256=
|
45
|
+
toolkits/system/shell_helper.py,sha256=sjoeVczxRyn_45bm-M95nAbEmz3ENffiWraivCxL0o4,9632
|
46
46
|
toolkits/system/str_helper.py,sha256=89qw0jF6Pf19uuMhBh7XFoCxHvEiZztPwlCDdYuPBEQ,5096
|
47
47
|
toolkits/system/tasks_deamon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
48
48
|
toolkits/system/tasks_deamon/tasks_controller.py,sha256=aobnJ0vJmvHQs94-yXasHqyxGsBHrv8Vqd1lq6JtmOo,2380
|
@@ -53,4 +53,4 @@ toolkits/system/time_helper.py,sha256=_nxy97rnnagCn_m5sppZTDsx2sdn5debsTfXPEjoWz
|
|
53
53
|
toolkits/system/win32_env.py,sha256=KYkZ-clZYkSQnSvPvpydeOVepaCrPH0egkC-MY-Bs0w,1829
|
54
54
|
toolkits/tookits_app.py,sha256=2qz6V5XkEGc6NjxafFvFavE1hpt-tE0PoGonLAvZNXs,380
|
55
55
|
toolkits/tookits_cli.py,sha256=PZmhHLqm8rhLOl3_Fty6WPkW4UxIHMGcswxaHrOe_Ek,5274
|
56
|
-
toolkits-0.2.
|
56
|
+
toolkits-0.2.9.dist-info/RECORD,,
|
File without changes
|