锦绣良缘tvb国语中字:在twisted 应用中使用了多线程,怎么不能使用Ctrl C 杀死应用?
来源:百度文库 编辑:九乡新闻网 时间:2024/04/27 13:48:15
--
Boern Parx
You must Sign in before you can post messages.To post a message you must first join this group.Please update your nickname on the subscription settings page before posting.You do not have the permission required to post.
View profile Translate to English Translated (View Original) More options Apr 1 2010, 2:27 pm From: 机械唯物主义 : linjunhalida
线程是不是没有释放?比如跑的是while loop?
上代码。
2010/4/1 Boern
- Hide quoted text - - Show quoted text -
> 如题,现在只能用windows任务管理器来杀死python进程,什么原因呢?> --
> Boern Parx
> --
> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
> 详情: https://groups.google.com/group/python-cn
> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
You must Sign in before you can post messages. To post a message you must first join this group. Please update your nickname on the subscription settings page before posting. You do not have the permission required to post.
Boern View profile Translate to English Translated (View Original) More options Apr 1 2010, 2:57 pm From: Boern
是,while loop 这样的线程,如何释放?是不是需要设置退出标志?
2010/4/1 机械唯物主义 : linjunhalida
- Hide quoted text - - Show quoted text -
> 线程是不是没有释放?比如跑的是while loop?> 上代码。
> 2010/4/1 Boern
>> 如题,现在只能用windows任务管理器来杀死python进程,什么原因呢?
>> --
>> Boern Parx
>> --
>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>> 详情: https://groups.google.com/group/python-cn
>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
> --
> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
> 详情: https://groups.google.com/group/python-cn
> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
Boern Parx
You must Sign in before you can post messages. To post a message you must first join this group. Please update your nickname on the subscription settings page before posting. You do not have the permission required to post.
View profile Translate to English Translated (View Original) More options Apr 1 2010, 3:01 pm From: 机械唯物主义 : linjunhalida
要通知线程关闭的。不然线程会一直跑下去。
可以用一个标志位来实现,线程如果发现标志位为true,就退出。
2010/4/1 Boern
- Hide quoted text - - Show quoted text -
> 是,while loop 这样的线程,如何释放?是不是需要设置退出标志?> 2010/4/1 机械唯物主义 : linjunhalida
> 线程是不是没有释放?比如跑的是while loop?
>> 上代码。
>> 2010/4/1 Boern
>>> 如题,现在只能用windows任务管理器来杀死python进程,什么原因呢?
>>> --
>>> Boern Parx
>>> --
>>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>>> 详情: https://groups.google.com/group/python-cn
>>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
>> --
>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>> 详情: https://groups.google.com/group/python-cn
>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
> --
> Boern Parx
> --
> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
> 详情: https://groups.google.com/group/python-cn
> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
You must Sign in before you can post messages. To post a message you must first join this group. Please update your nickname on the subscription settings page before posting. You do not have the permission required to post.
头太晕 View profile Translate to English Translated (View Original) More options Apr 1 2010, 3:32 pm From: 头太晕
2010/4/1 机械唯物主义 : linjunhalida
> 可以用一个标志位来实现,线程如果发现标志位为true,就退出。
对每个线程setDaemon(True)
如果你用了twisted的线程池,可以在程序最开始的地方加上这样的代码:
import threading
def threadFactory(*args,**kwargs):
t = threading.Thread(**kwargs)
t.setDaemon(True)
return t
from twisted.python import threadpool
threadpool.ThreadPool.threadFactory = threadFactory
这样,当你的主线程退出以后,其它线程就会全部退出。
- Hide quoted text - - Show quoted text -
> 2010/4/1 Boern>> 是,while loop 这样的线程,如何释放?是不是需要设置退出标志?
>> 2010/4/1 机械唯物主义 : linjunhalida
>> 线程是不是没有释放?比如跑的是while loop?
>>> 上代码。
>>> 2010/4/1 Boern
>>>> 如题,现在只能用windows任务管理器来杀死python进程,什么原因呢?
>>>> --
>>>> Boern Parx
>>>> --
>>>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>>>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>>>> 详情: https://groups.google.com/group/python-cn
>>>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
>>> --
>>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>>> 详情: https://groups.google.com/group/python-cn
>>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
>> --
>> Boern Parx
>> --
>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>> 详情: https://groups.google.com/group/python-cn
>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
> --
> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
> 详情: https://groups.google.com/group/python-cn
> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
You must Sign in before you can post messages. To post a message you must first join this group. Please update your nickname on the subscription settings page before posting. You do not have the permission required to post.
eric View profile Translate to English Translated (View Original) More options Apr 1 2010, 4:15 pm From: eric
while reactor.running:
loop code...
在 2010年4月1日 下午3:32,头太晕
- Hide quoted text - - Show quoted text -
> 2010/4/1 机械唯物主义 : linjunhalida
>> 要通知线程关闭的。不然线程会一直跑下去。
>> 可以用一个标志位来实现,线程如果发现标志位为true,就退出。
> 对每个线程setDaemon(True)
> 如果你用了twisted的线程池,可以在程序最开始的地方加上这样的代码:
> import threading
> def threadFactory(*args,**kwargs):
> t = threading.Thread(**kwargs)
> t.setDaemon(True)
> return t
> from twisted.python import threadpool
> threadpool.ThreadPool.threadFactory = threadFactory
> 这样,当你的主线程退出以后,其它线程就会全部退出。
>> 2010/4/1 Boern
>>> 是,while loop 这样的线程,如何释放?是不是需要设置退出标志?
>>> 2010/4/1 机械唯物主义 : linjunhalida
>>> 线程是不是没有释放?比如跑的是while loop?
>>>> 上代码。
>>>> 2010/4/1 Boern
>>>>> 如题,现在只能用windows任务管理器来杀死python进程,什么原因呢?
>>>>> --
>>>>> Boern Parx
>>>>> --
>>>>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>>>>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>>>>> 详情: https://groups.google.com/group/python-cn
>>>>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
>>>> --
>>>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>>>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>>>> 详情: https://groups.google.com/group/python-cn
>>>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
>>> --
>>> Boern Parx
>>> --
>>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>>> 详情: https://groups.google.com/group/python-cn
>>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
>> --
>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>> 详情: https://groups.google.com/group/python-cn
>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
> --
> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
> 详情: https://groups.google.com/group/python-cn
> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
You must Sign in before you can post messages. To post a message you must first join this group. Please update your nickname on the subscription settings page before posting. You do not have the permission required to post.
Boern View profile Translate to English Translated (View Original) More options Apr 1 2010, 5:22 pm From: Boern
非常感谢,回头我去试试!
2010/4/1 头太晕
- Hide quoted text - - Show quoted text -
> 2010/4/1 机械唯物主义 : linjunhalida
>> 要通知线程关闭的。不然线程会一直跑下去。
>> 可以用一个标志位来实现,线程如果发现标志位为true,就退出。
> 对每个线程setDaemon(True)
> 如果你用了twisted的线程池,可以在程序最开始的地方加上这样的代码:
> import threading
> def threadFactory(*args,**kwargs):
> t = threading.Thread(**kwargs)
> t.setDaemon(True)
> return t
> from twisted.python import threadpool
> threadpool.ThreadPool.threadFactory = threadFactory
> 这样,当你的主线程退出以后,其它线程就会全部退出。
>> 2010/4/1 Boern
>>> 是,while loop 这样的线程,如何释放?是不是需要设置退出标志?
>>> 2010/4/1 机械唯物主义 : linjunhalida
>>> 线程是不是没有释放?比如跑的是while loop?
>>>> 上代码。
>>>> 2010/4/1 Boern
>>>>> 如题,现在只能用windows任务管理器来杀死python进程,什么原因呢?
>>>>> --
>>>>> Boern Parx
>>>>> --
>>>>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>>>>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>>>>> 详情: https://groups.google.com/group/python-cn
>>>>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
>>>> --
>>>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>>>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>>>> 详情: https://groups.google.com/group/python-cn
>>>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
>>> --
>>> Boern Parx
>>> --
>>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>>> 详情: https://groups.google.com/group/python-cn
>>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
>> --
>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>> 详情: https://groups.google.com/group/python-cn
>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
> --
> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
> 详情: https://groups.google.com/group/python-cn
> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
Boern Parx
You must Sign in before you can post messages. To post a message you must first join this group. Please update your nickname on the subscription settings page before posting. You do not have the permission required to post.
HD View profile Translate to English Translated (View Original) More options Apr 2 2010, 9:14 am From: HD
好贴,加精呀!
在 2010年4月1日 下午3:32,头太晕
- Hide quoted text - - Show quoted text -
> 2010/4/1 机械唯物主义 : linjunhalida
>> 要通知线程关闭的。不然线程会一直跑下去。
>> 可以用一个标志位来实现,线程如果发现标志位为true,就退出。
> 对每个线程setDaemon(True)
> 如果你用了twisted的线程池,可以在程序最开始的地方加上这样的代码:
> import threading
> def threadFactory(*args,**kwargs):
> t = threading.Thread(**kwargs)
> t.setDaemon(True)
> return t
> from twisted.python import threadpool
> threadpool.ThreadPool.threadFactory = threadFactory
> 这样,当你的主线程退出以后,其它线程就会全部退出。
>> 2010/4/1 Boern
>>> 是,while loop 这样的线程,如何释放?是不是需要设置退出标志?
>>> 2010/4/1 机械唯物主义 : linjunhalida
>>> 线程是不是没有释放?比如跑的是while loop?
>>>> 上代码。
>>>> 2010/4/1 Boern
>>>>> 如题,现在只能用windows任务管理器来杀死python进程,什么原因呢?
>>>>> --
>>>>> Boern Parx
>>>>> --
>>>>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>>>>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>>>>> 详情: https://groups.google.com/group/python-cn
>>>>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
>>>> --
>>>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>>>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>>>> 详情: https://groups.google.com/group/python-cn
>>>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
>>> --
>>> Boern Parx
>>> --
>>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>>> 详情: https://groups.google.com/group/python-cn
>>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
>> --
>> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
>> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
>> 详情: https://groups.google.com/group/python-cn
>> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
> --
> 来自: `python-cn`:CPyUG ~ 华蟒用户组 | 发言:python-cn@googlegroups.com
> 退订: http://tinyurl.com/45a9tb //针对163/qq邮箱:http://tinyurl.com/4dg6hc
> 详情: https://groups.google.com/group/python-cn
> 严正: 理解列表! 智慧提问! http://wiki.woodpecker.org.cn/moin/AskForHelp
HD(燃烧中的火)
我工作我快乐,我勤奋我收获。请与我一起快乐,与我一起收获。