Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compendium-v2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
compendium-v2
Commits
caab071d
Commit
caab071d
authored
1 year ago
by
Bjarke Madsen
Browse files
Options
Downloads
Patches
Plain Diff
patch threading without breaking everything
parent
3a374cd2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
compendium_v2/email/__init__.py
+3
-2
3 additions, 2 deletions
compendium_v2/email/__init__.py
test/test_send_mail.py
+1
-1
1 addition, 1 deletion
test/test_send_mail.py
with
4 additions
and
3 deletions
compendium_v2/email/__init__.py
+
3
−
2
View file @
caab071d
import
smtplib
import
smtplib
import
threading
import
logging
import
logging
from
threading
import
Thread
from
email.mime.multipart
import
MIMEMultipart
from
email.mime.multipart
import
MIMEMultipart
from
email.mime.text
import
MIMEText
from
email.mime.text
import
MIMEText
from
typing
import
Sequence
,
Union
from
typing
import
Sequence
,
Union
...
@@ -68,7 +69,7 @@ def send_mail(
...
@@ -68,7 +69,7 @@ def send_mail(
# spin off a thread since this can take some time..
# spin off a thread since this can take some time..
logger
.
debug
(
'
Sending email
'
)
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
()
thread
.
start
()
...
...
This diff is collapsed.
Click to expand it.
test/test_send_mail.py
+
1
−
1
View file @
caab071d
...
@@ -47,7 +47,7 @@ def test_signup_email_admin(app, mocked_admin_user, mocker):
...
@@ -47,7 +47,7 @@ def test_signup_email_admin(app, mocked_admin_user, mocker):
assert
decoded
==
message
assert
decoded
==
message
mocker
.
patch
(
'
compendium_v2.email._send_mail
'
,
_send_mail
)
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
:
with
test_user
(
app
)
as
user
:
send_admin_signup_notification
(
user
)
send_admin_signup_notification
(
user
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment