mirror of
https://github.com/simple-login/app.git
synced 2024-09-27 20:31:30 +02:00
wrap shield around aiospamc.check to avoid the task being canceled
This commit is contained in:
parent
4b697fc897
commit
5f8fff5af3
@ -36,6 +36,7 @@ import email
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
from asyncio import shield
|
||||||
from email import encoders
|
from email import encoders
|
||||||
from email.message import Message
|
from email.message import Message
|
||||||
from email.mime.application import MIMEApplication
|
from email.mime.application import MIMEApplication
|
||||||
@ -1466,7 +1467,7 @@ async def get_spam_score(message: Message) -> float:
|
|||||||
try:
|
try:
|
||||||
# wait for at max 300s which is the default spamd timeout-child
|
# wait for at max 300s which is the default spamd timeout-child
|
||||||
response = await asyncio.wait_for(
|
response = await asyncio.wait_for(
|
||||||
aiospamc.check(sa_input, host=SPAMASSASSIN_HOST), timeout=300
|
shield(aiospamc.check(sa_input, host=SPAMASSASSIN_HOST)), timeout=300
|
||||||
)
|
)
|
||||||
return response.headers["Spam"].score
|
return response.headers["Spam"].score
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
|
Loading…
Reference in New Issue
Block a user