summaryrefslogtreecommitdiffstats
path: root/wallace/module_invitationpolicy.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2018-07-27 10:22:18 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2018-07-27 10:22:18 +0200
commit3c5ce19ae3e2b5ed90d0924c89d15f0c7609f53b (patch)
treed3e08b8874fdabfc858633a1ceb9e906ea743a51 /wallace/module_invitationpolicy.py
parenta1c700d53d8a9b0405f7bc28f835ab5142d0f72d (diff)
downloadpykolab-3c5ce19ae3e2b5ed90d0924c89d15f0c7609f53b.tar.gz
Manage the pool processes such that they die after a limited quantity of time, and pick up messages from the spool asynchronously.
Summary: Reference T75735 Let a single worker process timeout itself Set the signal as late as possible Abstract the method to pickup messages from the spool, so that a new recurring Timer may pick up messages out of the spool Test Plan: * Run messages through it Reviewers: #pykolab_developers Subscribers: #pykolab_developers Differential Revision: https://git.kolab.org/D617
Diffstat (limited to 'wallace/module_invitationpolicy.py')
-rw-r--r--wallace/module_invitationpolicy.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/wallace/module_invitationpolicy.py b/wallace/module_invitationpolicy.py
index b0dfe4c..55ad940 100644
--- a/wallace/module_invitationpolicy.py
+++ b/wallace/module_invitationpolicy.py
@@ -19,6 +19,7 @@
import datetime
import os
+import signal
import tempfile
import time
from urlparse import urlparse
@@ -1290,8 +1291,14 @@ def send_update_notification(object, receiving_user, old=None, reply=True, sende
msg['From'] = Header(utils.str2unicode('%s' % orgname) if orgname else '')
msg['From'].append("<%s>" % orgemail)
+ seed = random.randint(0, 6)
+ alarm_after = (seed * 10) + 60
+ log.debug(_("Set alarm to %s seconds") % (alarm_after), level=8)
+ signal.alarm(alarm_after)
+
result = modules._sendmail(orgemail, receiving_user['mail'], msg.as_string())
log.debug(_("Sent update notification to %r: %r") % (receiving_user['mail'], result), level=8)
+ signal.alarm(0)
def send_cancel_notification(object, receiving_user, deleted=False, sender=None, comment=None):
"""
@@ -1354,8 +1361,14 @@ def send_cancel_notification(object, receiving_user, deleted=False, sender=None,
msg['From'] = Header(utils.str2unicode('%s' % orgname) if orgname else '')
msg['From'].append("<%s>" % orgemail)
+ seed = random.randint(0, 6)
+ alarm_after = (seed * 10) + 60
+ log.debug(_("Set alarm to %s seconds") % (alarm_after), level=8)
+ signal.alarm(alarm_after)
+
result = modules._sendmail(orgemail, receiving_user['mail'], msg.as_string())
log.debug(_("Sent cancel notification to %r: %r") % (receiving_user['mail'], result), level=8)
+ signal.alarm(0)
def is_auto_reply(user, sender_email, type):
accept_available = False