1 Star 0 Fork 0

乔峰伟/studyGit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
util.py 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
Your Name 提交于 2018-07-16 11:03 . dfcaesf
# coding:utf-8
import os, sys
import log
import logging
import threading
import multiprocessing
import time
logger = log.Logger('log.log', clevel=logging.DEBUG, Flevel=logging.INFO)
def exccmd(cmd):
try:
return os.popen(cmd).read()
except Exception:
return None
# 线程函数
class FuncThread(threading.Thread):
def __init__(self, func, *params, **paramMap):
threading.Thread.__init__(self)
self.func = func
self.params = params
self.paramMap = paramMap
self.rst = None
self.finished = False
def run(self):
self.rst = self.func(*self.params, **self.paramMap)
self.finished = True
def getResult(self):
return self.rst
def isFinished(self):
return self.finished
def doInThread(func, *params, **paramMap):
t_setDaemon = None
if 't_setDaemon' in paramMap:
t_setDaemon = paramMap['t_setDaemon']
del paramMap['t_setDaemon']
ft = FuncThread(func, *params, **paramMap)
if t_setDaemon != None:
ft.setDaemon(t_setDaemon)
ft.start()
return ft
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/daqiv/studyGit.git
git@gitee.com:daqiv/studyGit.git
daqiv
studyGit
studyGit
master

搜索帮助