Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7673989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:38:18+00:00 2026-05-31T16:38:18+00:00

sometimes signals in django are triggered twice. In the docs it says that a

  • 0

sometimes signals in django are triggered twice. In the docs it says that a good way to create a (unique) dispatch_uid is either the path or name of the module[1] or the id of any hashable object[2].

Today I tried this:

import time
my_signal.connect(my_function, dispatch_uid=str(time.time()))

However I am afraid that in a multiuser environment (like in the case of a web site). This might be broken. What is a good and safe way to create such an id in a multiuser environment?

[1] https://code.djangoproject.com/wiki/Signals

[2] https://docs.djangoproject.com/en/dev/topics/signals/#preventing-duplicate-signals

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:38:19+00:00Added an answer on May 31, 2026 at 4:38 pm

    Using the time as a dispatch id won’t work. The issue isn’t whether your environment is multi-user or not. It’s whether the code that connects the signals is imported more than once.

    Say your module was imported twice, 5 seconds apart. You have effectively done the following.

    my_signal.connect(my_function, dispatch_uid=1332407342.51)
    my_signal.connect(my_function, dispatch_uid=1332407352.51)
    

    Your signal has been connected twice with different dispatch ids. This default project structure for Django 1.3 and earlier allows this double import to occur, as modules can often be imported as project.my_app.module and my_app.module.

    If you choose a convention like my_app.models.function_name as Dmitry suggests, then the second time the module is imported, the signal will not be connected twice because the dispatch id has not changed. It’s up to you not to reuse the same dispatch id to register different callback functions with the same signal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sometimes there are sites that have some small information window thats always visible when
Sometimes I have to work on code that moves the computer clock forward. In
I have an ncurses app that does the following, sometimes instantly after launch, sometimes
The documentation for dispatch_semaphore_wait says that it waits in FIFO order for a signal.
I have designed a django app that will plot and export large chunks of
I've noticed that AutoResetEvent completely freezes the message loop (sometimes) when in the middle
Sometimes I encounter cases where I have to attach a method to a delegate
Sometimes when i am trying to connect to my server through filezilla i am
Sometimes it is useful to get the type name from static invoke, see this
Sometimes when I'm editing page or control the .designer files stop being updated with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.