本文整理汇总了Python中executor.Executor.start方法的典型用法代码示例。如果您正苦于以下问题:Python Executor.start方法的具体用法?Python Executor.start怎么用?Python Executor.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类executor.Executor
的用法示例。
在下文中一共展示了Executor.start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _process_event
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import start [as 别名]
def _process_event(self, event):
global config
if event:
# This still needs some work
# dependencies = self._check_for_dependencies(config, event)
dependencies = []
self.job_count += 1
job_id = "%s:%d" % (self.name, self.job_count)
try:
# Launch test runs
tests = []
for test in config['tests']:
testexec = Executor(test, event, dependencies)
tests.append(testexec)
testexec.start()
logging.info('Started %s test execution...',
test['test-name'])
# Wait for all executions to finish
for test in tests:
test.join()
logging.info('All tests completed')
# Report the results
self._publish_results_to_gerrit(
config, tests, job_id)
# Throttle things a little bit
time.sleep(5)
except Exception:
logging.exception('Error in event processing!')
示例2: put
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import start [as 别名]
def put(self, project_name, task):
""" Put the task to the executor thread associated to the project name.
If the thread does not exist, it will be created.
"""
# Get the executor thread associated to the project name.
executor = self.executors.get(project_name)
if not executor:
# The thread does not exist yet. Create a new one.
executor = Executor()
# Associate this new thread to the project_name.
self.executors[project_name] = executor
# Start the thread.
executor.start()
# Put the task to the good executor thread.
executor.tasks.put(task)
示例3: execute
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import start [as 别名]
def execute():
"""
Create execution semaphore and threads.
Join threads and returns result files.
"""
resultfiles = []
threads = []
semaphore = threading.BoundedSemaphore(value=Configuration.semaphore)
for (root, dirs, files) in os.walk(Configuration.sourcedir):
for file in files:
# path manipulation
abspath = os.path.join(root, file)
relpath = os.path.relpath(abspath, Configuration.sourcedir)
# Resultdir
resdir = os.path.join(Configuration.resultdir, os.path.dirname(relpath))
# Create resultdir
if not os.path.exists(resdir):
os.makedirs(resdir)
e = Executor(relpath, file, semaphore)
e.start()
threads.append(e)
for t in threads:
t.join()
que = Executor.get_queue()
while que.empty() != True:
resultfiles = resultfiles + que.get()
return resultfiles
示例4: open
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import start [as 别名]
logging.basicConfig(
format='%(asctime)s %(name)s %(levelname)s: %(message)s',
level=logging.DEBUG)
logging.getLogger('paramiko').setLevel(logging.WARNING)
logging.getLogger('requests').setLevel(logging.WARNING)
requests.packages.urllib3.disable_warnings()
json_data = open('test.config')
config = json.load(json_data)
json_data.close()
event = json.loads(
'{"patchSet": { "ref": '
'"refs/changes/95/176095/1", "number": "1" '
'}, "change": { "number": "176095" } }')
tests = []
for test in config['tests']:
logging.debug(test['test-name'])
testexec = Executor(test, event)
tests.append(testexec)
testexec.start()
# Wait for all executions to finish
for test in tests:
test.join()
# Report the results
for test in tests:
logging.info(test.get_results())