Merge pull request #329 from FlySnake/send_queue_overflow
In queues added option to remove first element on addind new if queue is full
This commit is contained in:
commit
881d9040c4
2 changed files with 8 additions and 3 deletions
|
@ -32,12 +32,17 @@ def _gevent_threads_enabled():
|
||||||
|
|
||||||
if _gevent_threads_enabled():
|
if _gevent_threads_enabled():
|
||||||
import gevent.queue as queue
|
import gevent.queue as queue
|
||||||
Queue = queue.JoinableQueue
|
_queue = queue.JoinableQueue
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
import queue
|
import queue
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import Queue as queue
|
import Queue as queue
|
||||||
Queue = queue.Queue
|
_queue = queue.Queue
|
||||||
|
class Queue(_queue):
|
||||||
|
def put(self, item, block=True, timeout=None):
|
||||||
|
if _queue.full(self):
|
||||||
|
_queue.get(self)
|
||||||
|
return _queue.put(self, item, block, timeout)
|
||||||
|
|
||||||
QueueEmpty = queue.Empty
|
QueueEmpty = queue.Empty
|
||||||
|
|
|
@ -291,7 +291,7 @@ class XMLStream(object):
|
||||||
self.event_queue = Queue()
|
self.event_queue = Queue()
|
||||||
|
|
||||||
#: A queue of string data to be sent over the stream.
|
#: A queue of string data to be sent over the stream.
|
||||||
self.send_queue = Queue()
|
self.send_queue = Queue(maxsize=256)
|
||||||
self.send_queue_lock = threading.Lock()
|
self.send_queue_lock = threading.Lock()
|
||||||
self.send_lock = threading.RLock()
|
self.send_lock = threading.RLock()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue