7

Out of nowhere I'm running into an issue with my Django application where it runs the "Performing System Checks" command very slow. If I start the server with

python manage.py runserver

It takes more then a minute or two for the server to actually start up. After that it works fine until I make an update and then it restarts the server and goes through the process of "performing system checks" again taking a few minutes to complete.

If I run

python -v manage.py check

It gets to this import

import 'netrc' # <_frozen_importlib_external.SourceFileLoader object at 0x11dce6748>

And then it just hangs for a minute or so and then continues fine.

If I run

python -v manage.py runserver

It runs through a list of imports and the sits on "Performing System Checks" for awhile and eventually continues on to start the server.

I'm running Django 2.1.1. Using 'PYENV' to manage different python versions and running this in a virtual environment. I read on a few other posts that this has something to do with installing MySQL version 5.7, which is something I did recently, but I went through and uninstalled it as completely as I causing HomeBrew and removing other references.

I've re-created my virtual environment. Reinstalled Python 3.6.0. I've tried using Python 3.6.4. None of that has helped.

This is a pretty big issue because I can't wait a few minutes between every update.

5
  • 2
    Run python -v manage.py check or runserver and you'll see what makes it slow.
    – Borut
    Dec 6, 2018 at 13:49
  • Thanks @borut that helped. It looks like it's getting stuck on this. /.pyenv/versions/3.6.0/lib/python3.6/__pycache__/netrc.cpython-36.pyc' import 'netrc' # <_frozen_importlib_external.SourceFileLoader object at 0x1172335c0> Dec 6, 2018 at 13:56
  • Updated the question to include this information. Dec 6, 2018 at 14:07
  • I can't really help you further. I'd delete netrc.cpython-36.pyc if I were you. Python will compile it again on next load.
    – Borut
    Dec 6, 2018 at 14:07
  • Running python -v manage.py check allows Django to clean all the temporary files and it automatically makes the runserver faster. I just tested it right now, I'm using Django 3.2.
    – ionecum
    May 5, 2022 at 21:45

1 Answer 1

4

I found the culprit. I have multiple settings files for different environments. That are set based on the environment variables. In order to grab the IP address from my elasticbeanstalk instances to add it to the allowed_hosts I was importing the requests library in one of my settings files. If I remove that it works as normal.

2
  • Same problem like me on my local development server. I solved it by pushing requests.get('169.254.169.254/latest/meta-data/local-ipv4').text (which looks up the IP on beanstalk) into an if clause that checks whether Django is run on the local or production server (on AWS)
    – Greg Holst
    Jun 16, 2019 at 11:50
  • Likewise, I was using Cloud Detect library: pypi.org/project/cloud-detect to check which platform the code is running on but it just took waaay too long to resolve in some cases ranging from 3-5 minutes....Terrible
    – Isaac T
    May 26 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.