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


Python _thread.exit方法代码示例

本文整理汇总了Python中_thread.exit方法的典型用法代码示例。如果您正苦于以下问题:Python _thread.exit方法的具体用法?Python _thread.exit怎么用?Python _thread.exit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在_thread的用法示例。


在下文中一共展示了_thread.exit方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: gpu_status

# 需要导入模块: import _thread [as 别名]
# 或者: from _thread import exit [as 别名]
def gpu_status(self,av_type_list):
        for t in av_type_list:
            cmd='nvidia-smi -q --display='+t
            #print('\nCMD:',cmd,'\n')
            r=os.popen(cmd)
            info=r.readlines()
            r.close()
            content = " ".join(info)
            #print('\ncontent:',content,'\n')
            index=content.find('Attached GPUs')
            s=content[index:].replace(' ','').rstrip('\n')
            self.t_send(s, toUserName='filehelper')
            time.sleep(.5)
        #th.exit()
#==============================================================================
# 
#============================================================================== 
开发者ID:QuantumLiu,项目名称:Neural-Headline-Generator-CN,代码行数:19,代码来源:wechat_utils.py

示例2: run_task

# 需要导入模块: import _thread [as 别名]
# 或者: from _thread import exit [as 别名]
def run_task(self, task):
    for try_number in range(self.times_to_retry + 1):
      self.__register_start(task)
      task.run()
      self.__register_exit(task)

      if task.exit_code == 0:
        break

      if try_number < self.times_to_retry:
        execution_number = self.__get_next_execution_number(task.test_id)
        # We need create a new Task instance. Each task represents a single test
        # execution, with its own runtime, exit code and log file.
        task = self.task_factory(task.test_binary, task.test_name,
                                 task.test_command, execution_number,
                                 task.last_execution_time, task.output_dir)

    with self.lock:
      if task.exit_code != 0:
        self.global_exit_code = task.exit_code 
开发者ID:google,项目名称:gtest-parallel,代码行数:22,代码来源:gtest_parallel.py

示例3: start_new_thread

# 需要导入模块: import _thread [as 别名]
# 或者: from _thread import exit [as 别名]
def start_new_thread(function, args, kwargs={}):
    """Dummy implementation of _thread.start_new_thread().

    Compatibility is maintained by making sure that ``args`` is a
    tuple and ``kwargs`` is a dictionary.  If an exception is raised
    and it is SystemExit (which can be done by _thread.exit()) it is
    caught and nothing is done; all other exceptions are printed out
    by using traceback.print_exc().

    If the executed function calls interrupt_main the KeyboardInterrupt will be
    raised when the function returns.

    """
    if type(args) != type(tuple()):
        raise TypeError("2nd arg must be a tuple")
    if type(kwargs) != type(dict()):
        raise TypeError("3rd arg must be a dict")
    global _main
    _main = False
    try:
        function(*args, **kwargs)
    except SystemExit:
        pass
    except:
        import traceback
        traceback.print_exc()
    _main = True
    global _interrupt
    if _interrupt:
        _interrupt = False
        raise KeyboardInterrupt 
开发者ID:war-and-code,项目名称:jawfish,代码行数:33,代码来源:_dummy_thread.py

示例4: exit

# 需要导入模块: import _thread [as 别名]
# 或者: from _thread import exit [as 别名]
def exit():
    """Dummy implementation of _thread.exit()."""
    raise SystemExit 
开发者ID:war-and-code,项目名称:jawfish,代码行数:5,代码来源:_dummy_thread.py

示例5: run

# 需要导入模块: import _thread [as 别名]
# 或者: from _thread import exit [as 别名]
def run(self):
    begin = time.time()
    with open(self.log_file, 'w') as log:
      task = subprocess.Popen(self.test_command, stdout=log, stderr=log)
      try:
        self.exit_code = sigint_handler.wait(task)
      except sigint_handler.ProcessWasInterrupted:
        thread.exit()
    self.runtime_ms = int(1000 * (time.time() - begin))
    self.last_execution_time = None if self.exit_code else self.runtime_ms 
开发者ID:google,项目名称:gtest-parallel,代码行数:12,代码来源:gtest_parallel.py

示例6: log_exit

# 需要导入模块: import _thread [as 别名]
# 或者: from _thread import exit [as 别名]
def log_exit(self, task):
    with self.stdout_lock:
      self.finished_tasks += 1
      self.out.transient_line("[%d/%d] %s (%d ms)"
                              % (self.finished_tasks, self.total_tasks,
                                 task.test_name, task.runtime_ms))
      if task.exit_code != 0:
        with open(task.log_file) as f:
          for line in f.readlines():
            self.out.permanent_line(line.rstrip())
        self.out.permanent_line(
          "[%d/%d] %s returned/aborted with exit code %d (%d ms)"
          % (self.finished_tasks, self.total_tasks, task.test_name,
             task.exit_code, task.runtime_ms))

    if self.output_dir is None:
      # Try to remove the file 100 times (sleeping for 0.1 second in between).
      # This is a workaround for a process handle seemingly holding on to the
      # file for too long inside os.subprocess. This workaround is in place
      # until we figure out a minimal repro to report upstream (or a better
      # suspect) to prevent os.remove exceptions.
      num_tries = 100
      for i in range(num_tries):
        try:
          os.remove(task.log_file)
        except OSError as e:
          if e.errno is not errno.ENOENT:
            if i is num_tries - 1:
              self.out.permanent_line('Could not remove temporary log file: ' + str(e))
            else:
              time.sleep(0.1)
            continue
        break 
开发者ID:google,项目名称:gtest-parallel,代码行数:35,代码来源:gtest_parallel.py

示例7: _clientTearDown

# 需要导入模块: import _thread [as 别名]
# 或者: from _thread import exit [as 别名]
def _clientTearDown(self):
        self.done.set()
        try:
            if hasattr(self, 'clientTearDown'):
                self.clientTearDown()
        except BaseException as e:
            self.queue.put(e)
        finally:			
            thread.exit() 
开发者ID:pylessard,项目名称:python-can-isotp,代码行数:11,代码来源:ThreadableTest.py

示例8: clientTearDown

# 需要导入模块: import _thread [as 别名]
# 或者: from _thread import exit [as 别名]
def clientTearDown(self):
        self.done.set()
        thread.exit() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:5,代码来源:test_socket.py

示例9: start

# 需要导入模块: import _thread [as 别名]
# 或者: from _thread import exit [as 别名]
def start(self, run):
    thread.start_new_thread(run)
    
    def stop(self):
        thread.exit() 
开发者ID:vishal-android-freak,项目名称:firebase-micropython-esp32,代码行数:7,代码来源:ufirebase.py


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