summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Treinish <mtreinish@kortar.org>2016-09-29 18:48:48 -0400
committerMatthew Treinish <mtreinish@kortar.org>2016-09-29 18:51:41 -0400
commit5ab09429a170a52f13ddb07a17251a13db216949 (patch)
tree5c78df6f33d583813a51233bc27187a3d8741ced
parentf3911397912641df15b10e4c45aedf7f5b51cb45 (diff)
Add config option to set the imap idle timeout
This commit adds a new config option to the imap section, idle-timeout, which is used to set the timeout duration for the idle call. By default imaplib2 sets this to 29mins. This if far too long especially on an imap server that doesn't have imap idle configured properly. What ends up happening is that all the lp events get bunched together and pushed to mqtt at once every 29mins. This isn't really useful as an event stream. So this makes it configurable and decreases the default setting to 1 min which seems like a much more useful default value, albeit at the cost of more imap traffic to fetch messages. Change-Id: I98fc9778f0adc548d28e7bbd8600f05ff4946ba2
Notes
Notes (review): Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Workflow+1: Matthew Treinish <mtreinish@kortar.org> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 21 Dec 2016 17:48:22 +0000 Reviewed-on: https://review.openstack.org/379849 Project: openstack-infra/lpmqtt Branch: refs/heads/master
-rw-r--r--README.rst1
-rw-r--r--lpmqtt/daemon.py6
2 files changed, 6 insertions, 1 deletions
diff --git a/README.rst b/README.rst
index a6e2eff..6530a42 100644
--- a/README.rst
+++ b/README.rst
@@ -51,6 +51,7 @@ configuration of the imap server you're connecting to:
51 * **delete-old** - Set this to *True* to have lpmqtt delete messages after it 51 * **delete-old** - Set this to *True* to have lpmqtt delete messages after it
52 finishes processing them. By default it will just mark them 52 finishes processing them. By default it will just mark them
53 as read. 53 as read.
54 * **idle-timeout** - The number of seconds to use for the idle timeout
54 55
55MQTT 56MQTT
56---- 57----
diff --git a/lpmqtt/daemon.py b/lpmqtt/daemon.py
index f009da0..304c956 100644
--- a/lpmqtt/daemon.py
+++ b/lpmqtt/daemon.py
@@ -111,6 +111,10 @@ def main():
111 imap_delete = config.getboolean('imap', 'delete-old') 111 imap_delete = config.getboolean('imap', 'delete-old')
112 else: 112 else:
113 imap_delete = False 113 imap_delete = False
114 if config.has_option('imap', 'imap-timeout'):
115 imap_idle_timeout = config.getint('imap', 'idle-timeout')
116 else:
117 imap_idle_timeout = 60
114 118
115 launchpad = lp.LPImapWatcher(imap_server, imap_user, imap_password, 119 launchpad = lp.LPImapWatcher(imap_server, imap_user, imap_password,
116 folder=imap_folder, ssl=imap_ssl, 120 folder=imap_folder, ssl=imap_ssl,
@@ -120,7 +124,7 @@ def main():
120 for event in events: 124 for event in events:
121 msg, topic = process_event(event, base_topic) 125 msg, topic = process_event(event, base_topic)
122 mqttqueue.publish_single(topic, msg) 126 mqttqueue.publish_single(topic, msg)
123 launchpad.imap.idle() 127 launchpad.imap.idle(timeout=imap_idle_timeout)
124 128
125if __name__ == "__main__": 129if __name__ == "__main__":
126 main() 130 main()