uwsgi and thread don't play nice

This commit is contained in:
finn 2024-08-05 14:22:32 +00:00
parent b65daf3784
commit 7c286e1235
2 changed files with 7 additions and 3 deletions

View File

@ -11,7 +11,9 @@ def send_email(subject, sender, recipients, text_body, html_body):
msg = Message(subject, sender=sender, recipients=recipients) msg = Message(subject, sender=sender, recipients=recipients)
msg.body = text_body msg.body = text_body
msg.html = html_body msg.html = html_body
Thread(target=send_async_email, args=(app, msg)).start() mail.send(msg)
# Thread works surprisingly badly behind uwsgi, just let a uwsgi worker do its thing instead.
#Thread(target=send_async_email, args=(app, msg)).start()
def send_password_reset_email(user): def send_password_reset_email(user):
token = user.get_reset_password_token() token = user.get_reset_password_token()

View File

@ -19,10 +19,12 @@
{% endfor %} {% endfor %}
</p> </p>
<p>{{ form.remember_me() }} {{ form.remember_me.label }}</p> <p>{{ form.remember_me() }} {{ form.remember_me.label }}</p>
<p>{{ form.submit }}</p> <p>
{{ form.submit }}
<a class="button" href="{{ url_for('register') }}">Register</a>
</p>
</form> </form>
<p><a href="{{ url_for('register') }}">Register Here</a></p>
<p><a href="{{ url_for('reset_password_request') }}">Reset Password</a></p> <p><a href="{{ url_for('reset_password_request') }}">Reset Password</a></p>