本文整理汇总了Python中six.moves._thread.start_new_thread方法的典型用法代码示例。如果您正苦于以下问题:Python _thread.start_new_thread方法的具体用法?Python _thread.start_new_thread怎么用?Python _thread.start_new_thread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类six.moves._thread
的用法示例。
在下文中一共展示了_thread.start_new_thread方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: log_metric
# 需要导入模块: from six.moves import _thread [as 别名]
# 或者: from six.moves._thread import start_new_thread [as 别名]
def log_metric(self, name, value, unit=None, global_step=None, extras=None):
"""Log the benchmark metric information to bigquery.
Args:
name: string, the name of the metric to log.
value: number, the value of the metric. The value will not be logged if it
is not a number type.
unit: string, the unit of the metric, E.g "image per second".
global_step: int, the global_step when the metric is logged.
extras: map of string:string, the extra information about the metric.
"""
metric = _process_metric_to_json(name, value, unit, global_step, extras)
if metric:
# Starting new thread for bigquery upload in case it might take long time
# and impact the benchmark and performance measurement. Starting a new
# thread might have potential performance impact for model that run on
# CPU.
thread.start_new_thread(
self._bigquery_uploader.upload_benchmark_metric_json,
(self._bigquery_data_set,
self._bigquery_metric_table,
self._run_id,
[metric]))
示例2: image_create
# 需要导入模块: from six.moves import _thread [as 别名]
# 或者: from six.moves._thread import start_new_thread [as 别名]
def image_create(request, **kwargs):
copy_from = kwargs.pop('copy_from', None)
data = kwargs.pop('data', None)
image = glanceclient(request).images.create(**kwargs)
if data:
thread.start_new_thread(image_update,
(request, image.id),
{'data': data,
'purge_props': False})
elif copy_from:
thread.start_new_thread(image_update,
(request, image.id),
{'copy_from': copy_from,
'purge_props': False})
return image
示例3: start
# 需要导入模块: from six.moves import _thread [as 别名]
# 或者: from six.moves._thread import start_new_thread [as 别名]
def start(self):
for _ in range(self.num_worker):
_thread.start_new_thread(self.do_work, tuple())
示例4: run
# 需要导入模块: from six.moves import _thread [as 别名]
# 或者: from six.moves._thread import start_new_thread [as 别名]
def run(self):
self._plugins.init_plugins()
self._dispatcher.start()
_thread.start_new_thread(self._keep_active, tuple())
_thread.start_new_thread(self._run_jobs, tuple())
self._dispatcher.loop()
示例5: _rtm_connect
# 需要导入模块: from six.moves import _thread [as 别名]
# 或者: from six.moves._thread import start_new_thread [as 别名]
def _rtm_connect(self):
self.bot._client.connect_websocket()
self._websocket = self.bot._client.websocket
self._websocket.sock.setblocking(0)
_thread.start_new_thread(self._rtm_read_forever, tuple())
示例6: log_run_info
# 需要导入模块: from six.moves import _thread [as 别名]
# 或者: from six.moves._thread import start_new_thread [as 别名]
def log_run_info(self, model_name, dataset_name, run_params, test_id=None):
"""Collect most of the TF runtime information for the local env.
The schema of the run info follows official/benchmark/datastore/schema.
Args:
model_name: string, the name of the model.
dataset_name: string, the name of dataset for training and evaluation.
run_params: dict, the dictionary of parameters for the run, it could
include hyperparameters or other params that are important for the run.
test_id: string, the unique name of the test run by the combination of key
parameters, eg batch size, num of GPU. It is hardware independent.
"""
run_info = _gather_run_info(model_name, dataset_name, run_params, test_id)
# Starting new thread for bigquery upload in case it might take long time
# and impact the benchmark and performance measurement. Starting a new
# thread might have potential performance impact for model that run on CPU.
thread.start_new_thread(
self._bigquery_uploader.upload_benchmark_run_json,
(self._bigquery_data_set,
self._bigquery_run_table,
self._run_id,
run_info))
thread.start_new_thread(
self._bigquery_uploader.insert_run_status,
(self._bigquery_data_set,
self._bigquery_run_status_table,
self._run_id,
RUN_STATUS_RUNNING))
示例7: notifier
# 需要导入模块: from six.moves import _thread [as 别名]
# 或者: from six.moves._thread import start_new_thread [as 别名]
def notifier(self, name, args=None):
if args == None:
return None
self.observe_notification(args.get("notification"))
while args.get("running") == True:
np_name = self.get_notification(args.get("notification"))
if np_name:
userdata = args.get("userdata")
try:
thread.start_new_thread( args.get("callback") , (np_name, userdata, ) )
except:
self.logger.error("Error: unable to start thread")
示例8: subscribe
# 需要导入模块: from six.moves import _thread [as 别名]
# 或者: from six.moves._thread import start_new_thread [as 别名]
def subscribe(self, notification, cb, data=None):
np_data = {
"running": True,
"notification": notification,
"callback": cb,
"userdata": data,
}
thread.start_new_thread( self.notifier, ("NotificationProxyNotifier_"+notification, np_data, ) )
while(1):
time.sleep(1)
示例9: on_finish
# 需要导入模块: from six.moves import _thread [as 别名]
# 或者: from six.moves._thread import start_new_thread [as 别名]
def on_finish(self, status):
thread.start_new_thread(
self._bigquery_uploader.update_run_status,
(self._bigquery_data_set,
self._bigquery_run_status_table,
self._run_id,
status))