#22443 closed Cleanup/optimization (fixed)
Default value of smtp.EmailBackend.timeout not documented
| Reported by: | Baptiste Mispelon | Owned by: | mrezk | 
|---|---|---|---|
| Component: | Documentation | Version: | 1.6 | 
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | yes | UI/UX: | no | 
Description
Django 1.7 introduces a new timeout parameter for the SMTP email backend: https://docs.djangoproject.com/en/dev/topics/email/#django.core.mail.backends.smtp.EmailBackend.timeout
However, there's no mention of the default value for this parameter (is there one? If not, what happens if you don't specify it?).
Change History (13)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
| Owner: | changed from to | 
|---|---|
| Status: | new → assigned | 
comment:3 by , 12 years ago
So you think it is not worth to make clear that if unspecified, the default timeout will be default stmplib.STMP and stmplib.STMP_SSL timeout which ends up being socket._GLOBAL_DEFAULT_TIMEOUT?
follow-up: 5 comment:4 by , 12 years ago
I do think it's valuable to document the behavior.
As things are now, the way to find this out is to read the source of the smtplib module which is less than ideal.
comment:5 by , 12 years ago
Replying to bmispelon:
I do think it's valuable to document the behavior.
As things are now, the way to find this out is to read the source of the
smtplibmodule which is less than ideal.
What do you think about:
If unspecified,
timeoutdefault value will be the default value
used in either :class:smtplib.SMTPor :class:smtplib.SMTP_SSL
(depending if the keyword argumentuse_sslisTrue) which
is :data:socket._GLOBAL_DEFAULT_TIMEOUTfor both cases.
follow-up: 8 comment:6 by , 12 years ago
From what I understand, smtplib.SMTP doesn't have a default timeout of its own so if nothing is specified, socket.gettimeout() is what's going to be used (and if that's None, which I believe is the default, it means there won't be a timeout).
I think there's a way to cross link our documentation to python's official one (your current :class: one doesn't work I think) so if you could find how to do that, it'd be nice.
Thanks.
comment:7 by , 12 years ago
| Has patch: | set | 
|---|---|
| Patch needs improvement: | set | 
PR here: https://github.com/django/django/pull/2561
I'm marking as patch needs improvement per my previous comment.
comment:8 by , 12 years ago
| Has patch: | unset | 
|---|---|
| Patch needs improvement: | unset | 
Replying to bmispelon:
From what I understand,
smtplib.SMTPdoesn't have a default timeout of its own so if nothing is specified,socket.gettimeout()is what's going to be used (and if that'sNone, which I believe is the default, it means there won't be a timeout).
I think there's a way to cross link our documentation to python's official one (your current
:class:one doesn't work I think) so if you could find how to do that, it'd be nice.
Thanks.
Thanks for the quick reply! Am I checking the wrong source code? As I can see here: http://hg.python.org/cpython/file/2.7/Lib/smtplib.py#l235, smtplib.SMTP explicitly sets timeout to socket._GLOBAL_DEFAULT_TIMEOUT.
:class: is working for me to cross link from django's documentation to python's official one. The element renders as  <a class="reference external" href="http://docs.python.org/library/smtplib.html#smtplib.SMTP_SSL" title="(in Python v2.7)"> which is correct. Is there another way to achieve the same result?
comment:9 by , 12 years ago
| Has patch: | set | 
|---|---|
| Patch needs improvement: | set | 
comment:12 by , 12 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | assigned → closed | 
To my knowledge there is no default timeout. Tracing it back to smtplib, back to socket. You need to specify one.