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


Python thread.exit方法代码示例

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


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

示例1: 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

示例2: 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

示例3: _push_notification_to_subscribers

# 需要导入模块: import thread [as 别名]
# 或者: from thread import exit [as 别名]
def _push_notification_to_subscribers(subscriptions, data):
    userio.say("Sending notification to " + str(subscriptions.count()) + " subscribers in a new thread...")
    for subscription in subscriptions:
        try:
            webpush(
                subscription_info=subscription,
                data=data,
                vapid_private_key=configuration.get_vapid_public_private_key_pair()[1],
                vapid_claims=VAPID_CLAIMS,
                #gcm_key=configuration.get_gcm_key(),
            )
        except Exception as e:
            userio.error("    ...unable to send notification: " + str(e))
            db.subscriptions.remove(subscription)
            userio.say("    ...removed subscription!")
    userio.ok("Finished sending notification.")
    thread.exit() 
开发者ID:milesmcc,项目名称:LibreNews-Server,代码行数:19,代码来源:push.py

示例4: 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

示例5: 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

示例6: 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:
        _traceback.print_exc()
    _main = True
    global _interrupt
    if _interrupt:
        _interrupt = False
        raise KeyboardInterrupt 
开发者ID:glmcdona,项目名称:meddle,代码行数:32,代码来源:dummy_thread.py

示例7: exit

# 需要导入模块: import thread [as 别名]
# 或者: from thread import exit [as 别名]
def exit():
    """Dummy implementation of thread.exit()."""
    raise SystemExit 
开发者ID:glmcdona,项目名称:meddle,代码行数:5,代码来源:dummy_thread.py

示例8: clientTearDown

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

示例9: timer

# 需要导入模块: import thread [as 别名]
# 或者: from thread import exit [as 别名]
def timer(no, interval):
    cnt = 0
    while cnt < 10:
        print 'Thread: (%d) Time:%s\n' % (no, time.ctime())
        time.sleep(interval)
        cnt += 1
    thread.exit()

#Use thread.start_new_thread() to create 2 new threads 
开发者ID:Akagi201,项目名称:learning-python,代码行数:11,代码来源:test_start_new_thread.py

示例10: add_num

# 需要导入模块: import thread [as 别名]
# 或者: from thread import exit [as 别名]
def add_num(name):
    global num
    while True:
        mylock.acquire() # Get the lock
        # Do something to the shared resource
        print('Thread %s locked! num=%s' % (name, str(num)))
        if num >= 5:
            print('Thread %s released! num=%s' % (name, str(num)))
            mylock.release()
            thread.exit()
        num += 1
        print('Thread %s released! num=%s' % (name, str(num)))
        mylock.release() # Release the lock. 
开发者ID:Akagi201,项目名称:learning-python,代码行数:15,代码来源:test_thread_lock.py

示例11: clientTearDown

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

示例12: _on_keyboard

# 需要导入模块: import thread [as 别名]
# 或者: from thread import exit [as 别名]
def _on_keyboard(self, key, x, y):
        if key == 'q':
            self.stop_flag = True
            thread.exit()
        if key == 'f':
            if not self._in_fullscreen:
                self._orig_w = self.win_width
                self._orig_h = self.win_height
                glutFullScreen()
                self._in_fullscreen = True
            else:
                glutReshapeWindow(self._orig_w, self._orig_h)
                self._in_fullscreen = False
        if key in ('w', 's', 'a', 'd'):
            if time() - self.prev_move_time > self.move_accel_dt or \
                    key != self.prev_move_key:
                self.move_velo = 0
            self.prev_move_time = time()
            self.prev_move_key = key
            self.move_velo += self.move_accel
            if key == 'w':
                self.camera.move_forawrd(self.move_velo)
            elif key == 's':
                self.camera.move_forawrd(-self.move_velo)
            elif key == 'a':
                self.camera.move_right(-self.move_velo)
            else:
                self.camera.move_right(self.move_velo) 
开发者ID:ppwwyyxx,项目名称:Stereo-Pose-Machines,代码行数:30,代码来源:__init__.py

示例13: stop

# 需要导入模块: import thread [as 别名]
# 或者: from thread import exit [as 别名]
def stop():
        """May be used to kill the thread, if it is not a daemon thread."""
        thread.exit() 
开发者ID:usableprivacy,项目名称:upribox,代码行数:5,代码来源:sniff_thread.py

示例14: cancel_transfer

# 需要导入模块: import thread [as 别名]
# 或者: from thread import exit [as 别名]
def cancel_transfer(self):
        if self.cancel_button["text"] == "Cancel":
            # If the cancel button says "Cancel" then we want to set the exit flag to True
            self._thread_should_exit = True
        elif self.cancel_button["text"] == "Clear":
            # Otherwise if the cancel button says "Clear" we have to remove the upload frame
            self.grid_forget() 
开发者ID:charlesdaniel,项目名称:s3_uploader,代码行数:9,代码来源:s3_uploader.py


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