当前位置: 首页>>代码示例>>Python>>正文


Python _thread.start_new_thread方法代码示例

本文整理汇总了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])) 
开发者ID:IntelAI,项目名称:models,代码行数:25,代码来源:logger.py

示例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 
开发者ID:CiscoSystems,项目名称:avos,代码行数:20,代码来源:glance.py

示例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()) 
开发者ID:attzonko,项目名称:mmpy_bot,代码行数:5,代码来源:utils.py

示例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() 
开发者ID:attzonko,项目名称:mmpy_bot,代码行数:8,代码来源:bot.py

示例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()) 
开发者ID:attzonko,项目名称:mmpy_bot,代码行数:7,代码来源:driver.py

示例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)) 
开发者ID:IntelAI,项目名称:models,代码行数:31,代码来源:logger.py

示例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") 
开发者ID:iOSForensics,项目名称:pymobiledevice,代码行数:17,代码来源:notification_proxy.py

示例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) 
开发者ID:iOSForensics,项目名称:pymobiledevice,代码行数:14,代码来源:notification_proxy.py

示例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)) 
开发者ID:PipelineAI,项目名称:models,代码行数:9,代码来源:logger.py


注:本文中的six.moves._thread.start_new_thread方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。