Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#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 Joel Vasallo, 10 years ago

To my knowledge there is no default timeout. Tracing it back to smtplib, back to socket. You need to specify one.

comment:2 by mrezk, 10 years ago

Owner: changed from nobody to mrezk
Status: newassigned

comment:3 by mrezk, 10 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?

comment:4 by Baptiste Mispelon, 10 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.

in reply to:  4 comment:5 by mrezk, 10 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 smtplib module which is less than ideal.

What do you think about:

If unspecified, timeout default value will be the default value
used in either :class:smtplib.SMTP or :class:smtplib.SMTP_SSL
(depending if the keyword argument use_ssl is True) which
is :data:socket._GLOBAL_DEFAULT_TIMEOUT for both cases.

comment:6 by Baptiste Mispelon, 10 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 Baptiste Mispelon, 10 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.

in reply to:  6 comment:8 by mrezk, 10 years ago

Has patch: unset
Patch needs improvement: unset

Replying to bmispelon:

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.

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?

Last edited 10 years ago by mrezk (previous) (diff)

comment:9 by mrezk, 10 years ago

Has patch: set
Patch needs improvement: set

comment:10 by mrezk, 10 years ago

Patch needs improvement: unset

Pull request updated

comment:11 by mrezk, 10 years ago

Pull request updated

comment:12 by Baptiste Mispelon <bmispelon@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 4e3d8ae61055dbb83d193585f2f36af6537b31cc:

Fixed #22443 -- Document smtp.EmailBackend.timeout default value

Django 1.7 introduces a new timeout parameter for the SMTP email backend:
http://docs.djangoproject.com/en/dev/topics/email/#django.core.mail.backends.smtp.EmailBackend.timeout

However, there was no mention of the default value for this parameter.

comment:13 by Baptiste Mispelon <bmispelon@…>, 10 years ago

In 5672b29d57bcd7041268727c0a288b33eb708af4:

[1.7.x] Fixed #22443 -- Document smtp.EmailBackend.timeout default value

Django 1.7 introduces a new timeout parameter for the SMTP email backend:
http://docs.djangoproject.com/en/dev/topics/email/#django.core.mail.backends.smtp.EmailBackend.timeout

However, there was no mention of the default value for this parameter.

Backport of 4e3d8ae61055dbb83d193585f2f36af6537b31cc from master.

Note: See TracTickets for help on using tickets.
Back to Top