forked from celery/kombu
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emulation backend implemented with In-memory backend as the first exa…
…mple.
- Loading branch information
Ask Solem
committed
Jul 21, 2010
1 parent
61237a1
commit 2ff8ffc
Showing
6 changed files
with
171 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from Queue import Queue | ||
|
||
from kombu.backends import emulation | ||
|
||
|
||
class MemoryChannel(emulation.Channel): | ||
queues = {} | ||
do_restore = False | ||
|
||
def _new_queue(self, queue, **kwargs): | ||
self.queues[queue] = Queue() | ||
|
||
def _get(self, queue): | ||
return self.queues[queue].get(block=False) | ||
|
||
def _put(self, queue, message): | ||
self.queues[queue].put(message) | ||
|
||
def _purge(self, queue): | ||
size = self.queues[queue].qsize() | ||
self.queues[queue].queue.clear() | ||
return size | ||
|
||
|
||
class MemoryBackend(emulation.EmulationBase): | ||
Channel = MemoryChannel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.