-
Notifications
You must be signed in to change notification settings - Fork 100
Description
I'd rate this as a critical bug, unless a workaround has already been found (didn't see anything in my reading of the docs),
My asyncio process instantiates a Controller, then starts it. In the separate thread started by the Controller object, aiosmtpd opens an inbound port and listens for sessions. So far so good, all pretty normal.
But at times when multiple external clients are simultaneously injecting large-ish (>5MB) messages, the entire python process -- all event loops, all threads -- grinds to a complete halt.
My tests have been to get an external machine to simultaneously inject 10 messages, of 20MB each, into my SMTPD port. I provide my Controller object with a null stub handle_DATA() hook, which simply returns "250 Accepted".
Every time I run this test, the entire process freezes for between 10.5 and 18 seconds, until the injections are complete.
I'm guessing this is a GIL issue. My "main" thread and asyncio event loop freezes, along with everything running within that process.
I'm considering a radical option of spawning a separate aiosmtpd-based subprocess, and having its handle_DATA() hook throw the received envelopes into a pipeline, where they get pickled then base64'ed and passed via subproc stdout to the parent process.
I truly hope there's a better way. Can anyone please advise a more satisfactory remedy or workaround?