mirror of
https://github.com/simple-login/app.git
synced 2024-09-20 15:05:59 +08:00
use lock to handle 1 email at a time
This commit is contained in:
parent
d99d186bc0
commit
a3a99ac3f4
|
@ -1226,15 +1226,20 @@ async def get_spam_score(message: Message) -> float:
|
|||
|
||||
|
||||
class MailHandler:
|
||||
lock = asyncio.Lock()
|
||||
|
||||
async def handle_DATA(self, server, session, envelope: Envelope):
|
||||
try:
|
||||
ret = await self._handle(envelope)
|
||||
return ret
|
||||
except Exception:
|
||||
LOG.exception(
|
||||
"email handling fail %s -> %s", envelope.mail_from, envelope.rcpt_tos
|
||||
)
|
||||
return "421 SL Retry later"
|
||||
async with self.lock:
|
||||
try:
|
||||
ret = await self._handle(envelope)
|
||||
return ret
|
||||
except Exception:
|
||||
LOG.exception(
|
||||
"email handling fail %s -> %s",
|
||||
envelope.mail_from,
|
||||
envelope.rcpt_tos,
|
||||
)
|
||||
return "421 SL Retry later"
|
||||
|
||||
async def _handle(self, envelope: Envelope):
|
||||
start = time.time()
|
||||
|
|
Loading…
Reference in a new issue