#24380: First locmem email sent in tests is absurdly slow.
-------------------------------------+-------------------------------------
     Reporter:  fletom               |      Owner:  nobody
         Type:                       |     Status:  new
  Cleanup/optimization               |
    Component:  Core (Mail)          |    Version:  1.7
     Severity:  Normal               |   Keywords:  email fqdn performance
                                     |  tests
 Triage Stage:  Unreviewed           |  Has patch:  0
Easy pickings:  1                    |      UI/UX:  0
-------------------------------------+-------------------------------------
 Some of my application's tests send email. When running tests, Django sets
 `EMAIL_BACKEND` to be `django.core.mail.backends.locmem.EmailBackend`.
 This backend's `send_messages` calls `message.message()` on each email in
 order to do header validation. However, this has the side effect of
 generating a `Message-ID` email header, which calls `make_msgid()`, which
 ends up calling `socket.getfqdn()`. On my machine, `socket.getfqdn()`
 takes over 5 seconds to return. The `socket.getfqdn()` is cached,
 fortunately, so the 5 second delay only happens once.

 Five seconds may seem small but it is really significant when you're
 rapidly alternating between writing code and running tests, and it's
 totally unnecessary to set a `Message-ID` header on emails in
 `django.core.mail.backends.locmem`. Right now my large test suite runs in
 600 ms if I comment out that one pesky call that turns it into 5800 ms. So
 while this isn't a bug, I think fixing it would be a really nice quality-
 of-life change.

--
Ticket URL: <https://code.djangoproject.com/ticket/24380>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.2fc4be9b7144e2945d7cebf6ef0fd5d7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to