use fork context of multiprocessing module to start mailer
This commit is contained in:
@@ -13,14 +13,14 @@
|
||||
#
|
||||
|
||||
import logging
|
||||
import multiprocessing as mp
|
||||
import smtplib
|
||||
|
||||
from multiprocessing import Process, Queue
|
||||
from queue import Full as QueueFull
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
queue = Queue(maxsize=50)
|
||||
queue = mp.Queue(maxsize=50)
|
||||
process = None
|
||||
|
||||
|
||||
@@ -72,7 +72,8 @@ def sendmail(smtp_host, smtp_port, qid, mailfrom, recipients, mail,
|
||||
|
||||
# start mailprocess if it is not started yet
|
||||
if process is None:
|
||||
process = Process(target=mailprocess)
|
||||
ctx = mp.get_context('fork')
|
||||
process = ctx.Process(target=mailprocess)
|
||||
process.daemon = True
|
||||
logger.debug("starting mailer process")
|
||||
process.start()
|
||||
|
||||
Reference in New Issue
Block a user