带公共停止信号的可停止线程
attentive的Python项目详细描述
===
图片::https://readthedocs.org/projects/attentive/badge/?version=latest
:目标:http://attention.readthedocs.io/en/latest/?徽章=最新
:alt:文档状态
…图片::https://github.com/sthysel/attentive/blob/master/docs/attentive.jpg?原始=真
…代码::python
名称:
stoppablethread.\uu init(self)
self.name=name
def run(self):
print('{}已加快。format(self.name))
而不是self。stopped:
self.sleep(randint(1,10))
print('{}抛出一个{}'。format(self.name,randint(1,(6))
print('{}expires'。format(self.name))
with man('trump')、man('wang')、man('erdo湫an'):
while not quit.is湫set():
quit.wait(1)
巴什
>特朗普加快了王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王王;
特朗普投了一个
cerdo湫an抛出一个
erdo湫an expires
wang抛出一个
wang expires
trump抛出一个
trump expires
如果需要在sig int或sig湫term上连接一些需要清理的工作线程,请使用“注意”。
``stoppablethread``是上下文管理的线程,在上下文中生存。一旦它存在
上下文,它就设置它的内部停止标志,周期性地检查状态。这是一个允许线程干净退出的线程状态。
BR/>外部状态是由一个信号事件控制的,退出主上下文循环。
BR/>内部使用在BB/>睡眠期间中断的中断线程(睡眠)(方法)。< BR/> BR/>安装。代码:
$pip install attentive
install from source
…代码:
$pip安装。