[Django] #24228: Signals have unclear & inconsistent transaction handling

8 views
Skip to first unread message

Django

unread,
Jan 27, 2015, 1:22:35 PM1/27/15
to django-...@googlegroups.com
#24228: Signals have unclear & inconsistent transaction handling
-------------------------------------+-------------------------------------
Reporter: Gaffney | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Keywords: transaction, signals,
Severity: Normal | documentation
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Hello

The [https://docs.djangoproject.com/en/1.7/ref/signals/ signals
documentation] says nothing about transactions.

Looking in deletion.py,
[https://github.com/django/django/blob/fb48eb05816b1ac87d58696cdfe48be18c901f16/django/db/models/deletion.py#L282-L288
pre_delete and post_delete are within a transaction].

In base.py, however,
[https://github.com/django/django/blob/378a0d27d630386c1b0a53d4a2d48be767453198/django/db/models/base.py#L717-L719
pre_save] and
[https://github.com/django/django/blob/378a0d27d630386c1b0a53d4a2d48be767453198/django/db/models/base.py#L730-L732
post_save] are ''not'' within a transaction.

Whether this inconsistency is a bug is beyond my Django knowledge to
determine, but regardless, '''it should be clear in the documentation what
signals are within transactions'''.

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

Django

unread,
Jan 27, 2015, 3:53:24 PM1/27/15
to django-...@googlegroups.com
#24228: Signals have unclear & inconsistent transaction handling
-------------------------------------+-------------------------------------
Reporter: Gaffney | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: transaction, | Triage Stage: Accepted
signals, documentation |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* needs_better_patch: => 0
* needs_docs: => 0
* version: 1.7 => master
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

I think the `pre_save` should really be inside the same transaction as the
`save` part. I'm a bit less convinced about the `post_save` (that is
should a `post_save` error be able to "cancel" a `save`?), but it might be
the case also.

--
Ticket URL: <https://code.djangoproject.com/ticket/24228#comment:1>

Reply all
Reply to author
Forward
0 new messages