Discussion:
Post_save signal gets triggered twice
meppum
2008-04-20 05:29:53 UTC
Permalink
Has anyone noticed that the post_save signal gets triggered twice?

http://groups.google.com/group/django-users/browse_thread/thread/f002677029c042e8/0c27b48d464f9772?lnk=gst&q=signal+twice#0c27b48d464f9772
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Malcolm Tredinnick
2008-04-20 05:36:11 UTC
Permalink
Post by meppum
Has anyone noticed that the post_save signal gets triggered twice?
Under what circumstances? With what version of Django?

It doesn't happen all the time, so you're going to have to provide some
details.

Malcolm
--
Honk if you love peace and quiet.
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
meppum
2008-04-20 20:26:24 UTC
Permalink
Okay, it took me a while to figure out exactly what seems to be the
"on/off" switch or the root of the problem. It seems when I have ANY
extra entries in the urls.py file other then the admin file that the
post_save signal is getting fired twice on all of my models. Any idea
why that might be happening? I've included my url file.

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^accounts/', include('website.registration.urls')),
(r'^map/', 'website.employment.views.map'),
(r'^admin/', include('django.contrib.admin.urls')),
)
Post by Malcolm Tredinnick
Post by meppum
Has anyone noticed that the post_save signal gets triggered twice?
Under what circumstances? With what version of Django?
It doesn't happen all the time, so you're going to have to provide some
details.
Malcolm
--
Honk if you love peace and quiet.http://www.pointy-stick.com/blog/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
meppum
2008-04-20 20:28:16 UTC
Permalink
I'm using the truk version of django. Updated today.
Post by meppum
Okay, it took me a while to figure out exactly what seems to be the
"on/off" switch or the root of the problem. It seems when I have ANY
extra entries in the urls.py file other then the admin file that the
post_save signal is getting fired twice on all of my models. Any idea
why that might be happening? I've included my url file.
from django.conf.urls.defaults import *
urlpatterns = patterns('',
    (r'^accounts/', include('website.registration.urls')),
    (r'^map/', 'website.employment.views.map'),
    (r'^admin/', include('django.contrib.admin.urls')),
)
Post by Malcolm Tredinnick
Post by meppum
Has anyone noticed that the post_save signal gets triggered twice?
Under what circumstances? With what version of Django?
It doesn't happen all the time, so you're going to have to provide some
details.
Malcolm
--
Honk if you love peace and quiet.http://www.pointy-stick.com/blog/- Hide quoted text -
- Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
meppum
2008-04-20 20:36:37 UTC
Permalink
More information:

-I'm basically using signals to denormalize data
-To test I'm using the admin tool
-When a new object of type "foo" is created an object called
"statistics" is updated on post_save and a child record is created
for statistics. If I include url entries other then admin statistics
is updated twice. If i only include the admin url in the urls file
statistics is updated one.
Post by Malcolm Tredinnick
Post by meppum
Has anyone noticed that the post_save signal gets triggered twice?
Under what circumstances? With what version of Django?
It doesn't happen all the time, so you're going to have to provide some
details.
Malcolm
--
Honk if you love peace and quiet.http://www.pointy-stick.com/blog/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
meppum
2008-04-20 23:05:14 UTC
Permalink
I think I figured out what it is. After finding the post below which
referenced ticket #3951 it seems it's a known issue.

The last time the ticket was updated was June of 2007. Am I to
understand this is not going to be fixed? Is the workaround simply to
reference any module using signals to create other instances of
objects?

What I don't understand is why it seems to be so intermittent. I mean
I send emails on saves and I don't end up with two instances of them.
Post by Malcolm Tredinnick
Has anyone noticed that the post_save signal gets triggeredtwice?
Under what circumstances? With what version of Django?
It doesn't happen all the time, so you're going to have to provide some
details.
Malcolm
--
Honk if you love peace and quiet.http://www.pointy-stick.com/blog/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Malcolm Tredinnick
2008-04-21 05:15:30 UTC
Permalink
Post by meppum
I think I figured out what it is. After finding the post below which
referenced ticket #3951 it seems it's a known issue.
The last time the ticket was updated was June of 2007. Am I to
understand this is not going to be fixed?
If it wasn't going to be fixed, the ticket would be closed as wontfix.
In fact, that ticket is probably blocking on the signal rewrite that a
couple of people are working on. Then we can try and solve it robustly
(for example, it's possible that signals could register with some kind
of unique id so that duplicate registrations don't take place). There
are a few similar problem in Django (e.g. registering admin classes in
newforms-admin) and a reasonably consistent solution to all of them is a
good goal, too.

Regards,
Malcolm
--
Despite the cost of living, have you noticed how popular it remains?
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
meppum
2008-04-21 12:39:08 UTC
Permalink
Sounds good. I read over the ticket a few times and i'm a little fuzzy
on the last comment you made in it. For now I'd like to make sure that
in my code signals are only registered once. Based on the comments in
the ticket it seems that the only way to make sure that happens it to
fully qualify the reference path:

from <site_name>.<app_name>.<module> import *

is that correct?
Post by Malcolm Tredinnick
Post by meppum
I think I figured out what it is. After finding the post below which
referenced ticket #3951 it seems it's a known issue.
The last time the ticket was updated was June of 2007. Am I to
understand this is not going to be fixed?
If it wasn't going to be fixed, the ticket would be closed as wontfix.
In fact, that ticket is probably blocking on the signal rewrite that a
couple of people are working on. Then we can try and solve it robustly
(for example, it's possible that signals could register with some kind
of unique id so that duplicate registrations don't take place). There
are a few similar problem in Django (e.g. registering admin classes in
newforms-admin) and a reasonably consistent solution to all of them is a
good goal, too.
Regards,
Malcolm
--
Despite the cost of living, have you noticed how popular it remains?http://www.pointy-stick.com/blog/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Continue reading on narkive:
Loading...