#29846: Signals - handling multiple requests concurrently
-----------------------------------------+-------------------------
Reporter: anomitra | Owner: nobody
Type: Uncategorized | Status: new
Component: HTTP handling | Version: 1.11
Severity: Normal | Keywords: signals
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+-------------------------
I am using a `pre_save` signal to store the user who performed the last
operation on a particular instance.
To achieve this, I'm using a middleware. In the `process_request` function
of it, the signal is registered with the appropriate function, `set_user`
as shown below.
mark_who_did = curry(self.set_user, user)
models.signals.pre_save.connect(mark_who_did,
dispatch_uid=(self.__class__, request,), weak=False)
Then, I'm disconnecting this signal in the `process_response` function of
the middleware.
models.signals.pre_save.disconnect(dispatch_uid=(self.__class__,
request,))
This works fine when concurrency is not involved. However, suppose we have
three concurrent requests - the signal is connected three times, and the
`set_user` method is invoked **nine times**, for each user-request
combination.
As per my understanding, each request should have been operating
independently, but that is obviously not the case. Is there something I'm
missing, or is there something I could change in my code to fix this?
--
Ticket URL: <https://code.djangoproject.com/ticket/29846>
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/051.5f1e8474d7bb0b381c7a17a667cf4797%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.