#23641: Apps.set_installed_apps causes signals registered with apps as senders not to be received ------------------------------+------------------------------------ Reporter: wrwrwr | Owner: nobody Type: Bug | Status: closed Component: Core (Other) | Version: master Severity: Normal | Resolution: fixed Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ------------------------------+------------------------------------
Comment (by timgraham): Putting the original commit message here for posterity: {{{ In the case of the sites app, this solves a problem appearing when Apps.set_installed_apps() (override/modify_settings) is used before sending the post_migrate signal -- create_default_site() handler is not executed in such a case. To elaborate a bit, the signal is connected with the sender attribute equal to an AppConfig instance; the signal dispatcher stores its id to identify the sender that we're interested in receiving signals from. The set_installed_apps() method reinstantiates all AppConfigs, and when the migration machinery emits signals using these new app configs as senders, their ids don't match those stored by the dispatcher. Handlers registered before overriding installed apps are not called. Moving signal registration to ready() ensures that signals that use an app config as a sender will be connected for any new instance. On the other hand, the ready() method may be executed more than once during testing, so signals that expect other senders may need to be protected from double registration. }}} -- Ticket URL: <https://code.djangoproject.com/ticket/23641#comment:15> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.83b25de70e8d45ea6a8046f9027dfc5b%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.