Opened 4 years ago

Closed 4 years ago

Last modified 4 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 Changed 4 years ago by Joel Vasallo

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

comment:2 Changed 4 years ago by mrezk

Owner: changed from nobody to mrezk
Status: newassigned

comment:3 Changed 4 years ago by mrezk

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 Changed 4 years ago by Baptiste Mispelon

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 in reply to:  4 Changed 4 years ago by mrezk

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 Changed 4 years ago by Baptiste Mispelon

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 Changed 4 years ago by Baptiste Mispelon

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 in reply to:  6 Changed 4 years ago by mrezk

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 4 years ago by mrezk (previous) (diff)

comment:9 Changed 4 years ago by mrezk

Has patch: set
Patch needs improvement: set

comment:10 Changed 4 years ago by mrezk

Patch needs improvement: unset

Pull request updated

comment:11 Changed 4 years ago by mrezk

Pull request updated

comment:12 Changed 4 years ago by Baptiste Mispelon <bmispelon@…>

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 Changed 4 years ago by Baptiste Mispelon <bmispelon@…>

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