基于文件系统的弹性队列。
FsQueue的Python项目详细描述
python fsqueue是一个弹性同步队列类。
源代码
功能
fsqueue模块与python的queue类几乎相同。
- fsqueue是弹性的。
- fsqueue是多进程安全的。多进程可以使用fsqueue。
- fsqueue没有最大大小功能,因此full()始终返回false。
- fsqueue可以用作fifo队列。
一个简单的例子
示例:
import sys from multiprocessing import Process from FsQueue import Queue from time import sleep def put(q, num): for i in xrange(num): print "put:%d" % i sys.stdout.flush() q.put(i) def get(q, num): for i in xrange(num): sys.stdout.flush() print "get:%d %d" % (i, q.get()) q.task_done() def process_test(): q = Queue(init=True) p0 = Process(target=put, args=(q,1000)) p0.start() p0.join() p1 = Process(target=get, args=(q,500)) p2 = Process(target=get, args=(q,500)) p1.start() p2.start() p1.join() p2.join() if not q.empty(): print "Queue should be empty." raise Exception if __name__ == '__main__': process_test()
最近的更改日志
v1.2
- A quick example was changed.
v1.1
- First release