python 3.x - Django slow autoreload due to check_url_config system check -


my load , autoreload on python manage.py runserver taking lot of time. (25seconds+). did bit of digging , seems stuck on "performing system checks..". investigate more, added timer on each of check functions.

c:\programs\python35-32\python.exe manage.py runserver performing system checks...  self.check: check_default_cache_is_configured 0.0 self.check: check_duplicate_template_settings 0.0 self.check: check_all_models 0.028018712997436523 self.check: check_model_signals 0.0 self.check: check_setting_app_dirs_loaders 0.0 self.check: check_url_config 25.260559558868408 self.check: check_admin_app 0.0 self.check: check_user_model 0.0 self.check: check_generic_foreign_keys 0.0010006427764892578 system check identified no issues (0 silenced). self.check: 25.289578914642334 self.check_migrations: 0.08856558799743652 june 28, 2016 - 15:43:08 django version 1.9.6, using settings 'mar16_cookifi_com.settings' starting development server @ http://127.0.0.1:8000/ quit server ctrl-break. 

i found in check\urls.py, resolver.url_patterns taking long time.

def check_resolver(resolver):     """     recursively check resolver.     """     django.core.urlresolvers import regexurlpattern, regexurlresolver     warnings = []     pattern in resolver.url_patterns:         if isinstance(pattern, regexurlresolver): 
  1. i not sure how urlresolver.url_patterns taking long time. appreciate in understanding why takes 25 seconds load url_patters. can reduce this.

  2. at least, disable check_url_config. solution 1 more preferred.

added:

i manually disabled check function in django code. [edit] delayed problem first load, took 25 seconds.

@register(tags.urls) def check_url_config(app_configs, **kwargs):     return []     if getattr(settings, 'root_urlconf', none):         django.core.urlresolvers import get_resolver         resolver = get_resolver()         return check_resolver(resolver)     return [] 

the time reduces sub second:

c:\programs\python35-32\python.exe manage.py runserver performing system checks...  self.check: check_default_cache_is_configured 0.0 self.check: check_duplicate_template_settings 0.0 self.check: check_all_models 0.028048038482666016 self.check: check_model_signals 0.0 self.check: check_setting_app_dirs_loaders 0.0 self.check: check_url_config 0.0 self.check: check_admin_app 0.0 self.check: check_user_model 0.0 self.check: check_generic_foreign_keys 0.0 system check identified no issues (0 silenced). self.check: 0.028048038482666016 self.check_migrations: 0.06304526329040527 june 28, 2016 - 16:24:36 django version 1.9.6, using settings 'mar16_cookifi_com.settings' starting development server @ http://127.0.0.1:8000/ quit server ctrl-break. 

but have solution not modify django code.

after 1 more hour:

found cause of problem. url file loading our views. 1 of view added ml module takes 25 seconds train. making ml module lazy reduced loading time second.

django has silenced_system_checks prevents warnings being displayed, not have hook prevent check running.

you prevent url checks commenting out the import in django source code.

however, i'm not sure speed application. when url patterns loaded, django imports views @ same time. if disable url checks, django still need load url config later, suspect see similar delay. should investigate further find out included urls.py files , views taking long time load.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -