comparison queues/backends/dummy.py @ 20:b4184f99ed13

Added functionality for the dummy backend to make it behave more like a production backend for testability sake. Thanks to Travis Cline for the patch. Fixes issue #4.
author mcroydon
date Tue, 20 Oct 2009 22:01:12 +0000
parents 4473ee0eff6f
children 331d96e6a133
comparison
equal deleted inserted replaced
19:b2af7123f5e3 20:b4184f99ed13
5 """ 5 """
6 import Queue as queue 6 import Queue as queue
7 from queues import QueueException 7 from queues import QueueException
8 from queues.backends.base import BaseQueue 8 from queues.backends.base import BaseQueue
9 9
10 queues = {}
10 11
11 dummy_queue = queue.Queue() 12 def get_queue(name):
12 13 if name not in queues:
14 queues[name] = queue.Queue()
15 return queues[name]
13 16
14 class Queue(BaseQueue): 17 class Queue(BaseQueue):
15 def __init__(self, name='default'): 18 def __init__(self, name='default'):
16 self.queue = dummy_queue 19 self.queue = get_queue(name)
17 self.backend = 'dummy' 20 self.backend = 'dummy'
18 self.name = name 21 self.name = name
19 22
20 def read(self): 23 def read(self):
21 try: 24 try: