當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。