summaryrefslogtreecommitdiff
path: root/mail/src/leap
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-01-30 17:23:27 -0400
committerKali Kaneko <kali@leap.se>2014-01-30 17:23:27 -0400
commit6d3026770e1189a50e3a4d2f2467f5295388fb31 (patch)
tree5575c54576b0fc5fa2873780e61f6701e40e5ee4 /mail/src/leap
parent369897363f0fc4dae9dc7a024add97218b3bbbaf (diff)
skip notifications
Diffstat (limited to 'mail/src/leap')
-rw-r--r--mail/src/leap/mail/imap/mailbox.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/mail/src/leap/mail/imap/mailbox.py b/mail/src/leap/mail/imap/mailbox.py
index 2d1ab885..6c8d78db 100644
--- a/mail/src/leap/mail/imap/mailbox.py
+++ b/mail/src/leap/mail/imap/mailbox.py
@@ -22,6 +22,7 @@ import threading
import logging
import StringIO
import cStringIO
+import os
from collections import defaultdict
@@ -43,6 +44,12 @@ from leap.mail.imap.parser import MBoxParser
logger = logging.getLogger(__name__)
+"""
+If the environment variable `LEAP_SKIPNOTIFY` is set, we avoid
+notifying clients of new messages. Use during stress tests.
+"""
+NOTIFY_NEW = not os.environ.get('LEAP_SKIPNOTIFY', False)
+
class SoledadMailbox(WithMsgFields, MBoxParser):
"""
@@ -77,6 +84,7 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
CMD_UIDVALIDITY = "UIDVALIDITY"
CMD_UNSEEN = "UNSEEN"
+ # FIXME we should turn this into a datastructure with limited capacity
_listeners = defaultdict(set)
next_uid_lock = threading.Lock()
@@ -145,6 +153,8 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
:param listener: listener to add
:type listener: an object that implements IMailboxListener
"""
+ if not NOTIFY_NEW:
+ return
logger.debug('adding mailbox listener: %s' % listener)
self.listeners.add(listener)
@@ -421,6 +431,8 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
:param args: ignored.
"""
+ if not NOTIFY_NEW:
+ return
exists = self.getMessageCount()
recent = self.getRecentCount()
logger.debug("NOTIFY: there are %s messages, %s recent" % (