From caab071dc853506da569ec840aa7f1ea97bb1b11 Mon Sep 17 00:00:00 2001
From: Bjarke Madsen <bjarke@nordu.net>
Date: Sat, 2 Sep 2023 19:12:40 +0200
Subject: [PATCH] patch threading without breaking everything

---
 compendium_v2/email/__init__.py | 5 +++--
 test/test_send_mail.py          | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/compendium_v2/email/__init__.py b/compendium_v2/email/__init__.py
index 9e32a67e..dc8f4d68 100644
--- a/compendium_v2/email/__init__.py
+++ b/compendium_v2/email/__init__.py
@@ -1,6 +1,7 @@
 import smtplib
-import threading
 import logging
+
+from threading import Thread
 from email.mime.multipart import MIMEMultipart
 from email.mime.text import MIMEText
 from typing import Sequence, Union
@@ -68,7 +69,7 @@ def send_mail(
 
     # spin off a thread since this can take some time..
     logger.debug('Sending email')
-    thread = threading.Thread(target=_send_mail, args=(smtp_server, port, recipients, message))
+    thread = Thread(target=_send_mail, args=(smtp_server, port, recipients, message))
     thread.start()
 
 
diff --git a/test/test_send_mail.py b/test/test_send_mail.py
index 177b3e73..5cf46de6 100644
--- a/test/test_send_mail.py
+++ b/test/test_send_mail.py
@@ -47,7 +47,7 @@ def test_signup_email_admin(app, mocked_admin_user, mocker):
         assert decoded == message
 
     mocker.patch('compendium_v2.email._send_mail', _send_mail)
-    mocker.patch('threading.Thread', MockedThread)
+    mocker.patch('compendium_v2.email.Thread', MockedThread)
     with test_user(app) as user:
         send_admin_signup_notification(user)
 
-- 
GitLab