Opened 4 years ago

Closed 4 years ago

Last modified 13 months ago

#14916 closed Uncategorized (duplicate)

No proper initialization of models/signals/etc....

Reported by: Pakal Owned by: nobody
Component: Core (Other) Version: 1.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As discussed in http://groups.google.com/group/django-developers/browse_thread/thread/825c154c54f79ad9 ,
there is a real problem with the fact that, in production mode (mod_python, mod_wsgi...), no loading of installed applications occurs, contrarily to what we have in django's dev server.

This raises major issues, imo :

  • silent errors in the signaling framework : if a module isn't explicitely loaded by a view during request processing, the signal connections it contains will never be performed, so it makes the whole signaling framework quite broken.
  • no proper place to put startup code : a quick google search shows that people are multiplying awkward constructs to initialize their application, by putting code in settings.py (which is often loaded several times => problems), in urls.py (that's NOT the point of this module), in temporary ("one-shot") middlewares...

Wouldn't it be quite handier to give each application a chance to initialize at server (or rather, worker process) startup, by loading all models.py, or maybe better, all init.py from INSTALLED_APPS ?

Change History (4)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Closing as a duplicate of #3591, since signal instantiation is an issue of app startup.

comment:2 Changed 4 years ago by anonymous

  • Easy pickings unset
  • Resolution duplicate deleted
  • Severity set to Normal
  • Status changed from closed to reopened
  • Type set to Uncategorized
  • UI/UX unset

I'm sorry, but this issue is not a duplicate of issue #3591 - which doesn't deal with early import of models and signal setup.

Clearly at server startup, the first http requests are unlikely to trigger the import of all install apps, so signals might be issued whereas all their listeners aren't yet activated. Same for django models, whose relationship tree won't be complete...
That's a serious workflow issue imo, invalidating the principle of the signal system of django.

comment:3 Changed 4 years ago by aaugustin

  • Resolution set to duplicate
  • Status changed from reopened to closed

Please don't re-open tickets closed by core developers. As explained in the contributing guide, you should write to the django-developers mailing list instead.

comment:4 Changed 13 months ago by aaugustin

This was indeed fixed by app-loading, which landed in Django 1.7.

Note: See TracTickets for help on using tickets.
Back to Top