adaptive_thread_pool.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:Intranet-Penetration 作者: yuxiaokui 项目源码 文件源码
def InterruptibleSleep(sleep_time):
  """Puts thread to sleep, checking this threads exit_flag four times a second.

  Args:
    sleep_time: Time to sleep.
  """
  slept = 0.0
  epsilon = .0001
  thread = threading.currentThread()
  while slept < sleep_time - epsilon:
    remaining = sleep_time - slept
    this_sleep_time = min(remaining, 0.25)
    time.sleep(this_sleep_time)
    slept += this_sleep_time
    if thread.exit_flag:
      return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号