像标准的线程模块,但是awesomer
threading2的Python项目详细描述
线程2:类似于标准线程模块,但是是一个awesomer。
此模块设计为默认值的替换和扩展 “线程”模块。它有两个主要目标:
- implement primitives using native platform functionality where possible
- expose more sophisticated functionality where it can be done uniformly
当前实现了以下扩展:
- ability to set (advisory) thread priority
- ability to set (advisory) CPU affinity at thread and process level
- thread groups for simultaneous management of multiple threads
- SHLock class for shared/exclusive (also known as read/write) locks
还包括以下API细节:
- all blocking methods take a “timeout” argument and return a success code
- all exposed objects are actual classes and can be safely subclassed
这目前只在winxp和ubuntu karmic上测试过;类似的 平台应该正常工作,其他平台应该重新使用 合理的违约行为,但现阶段我不会做出任何保证。
其他计划的扩展包括:
- make stack_size a kwarg when creating a thread
- native events, semaphores and timed waits on win32
- native conditions and timed waits on pthreads platforms
- native SHLock implementations (SRW on Win Vista+, pthread_rwlock)