Django manage.py command hangs

3.4k views Asked by At

What worked perfectly normally before, has just given up on me. When using any type of manage.py command like below, I see Performing system checks...

python manage.py runserver 

or

python manage.py makemigrations

After about a 30-60 seconds of hanging, I then get:

System check identified no issues (0 silenced).

Which hangs and hangs and hangs...then after about 6 minutes, I see again the normal Quit the server with CONTROL-C To debug this issue, I even tried to comment out my apps and middleware, as well as shut down other applications on my PY and perform a reboot, still no change. What else do I need to look at with this? This seems far too long.

settings.py

import os
import logging

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SITE_ROOT = os.path.realpath(os.path.dirname(os.path.abspath(__file__)))
print ("SITE_ROOT: {0}".format(SITE_ROOT))
print ("BASE_DIR: {0}".format(BASE_DIR))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'blah'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'user_auth',
    #'users',
]

#Handle session is not Json Serializable
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'

#Parameters for setting the expiry
SESSION_SAVE_EVERY_REQUEST = True
SESSION_EXPIRE_AT_BROWSER_CLOSE  = True
SESSION_COOKIE_AGE = 10

LDAP_SERVER = '10.253.8.31'
LDAP_AUTH_SEARCH_BASE = "ou=Konzern, dc=compnayx, dc=de"  # The LDAP search base for looking up users.
DOMAIN_NAME = 'MyDomain'


AUTHENTICATION_BACKENDS = (  
    'django.contrib.auth.backends.ModelBackend',
)

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    #'UserAuth.Middleware.ldap_interface.LDAP_Auth_Backend',
]

# Auto logout delay in minutes
AUTO_LOGOUT_DELAY = 1 #equivalent to 1 minutes

ROOT_URLCONF = 'UserAuth.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'UserAuth.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'

USE_I18N = True
USE_L10N = True
USE_TZ = False # Does not assume timestamps in DB are all in UTC


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/

STATIC_URL = '/static/'

ADMINS = (
  ('me', 'myemail'),
)
MAILER_LIST = ['myemail']          # To whom shall the mail be sent
EMAIL_HOST = 'smtp-mail.outlook.com'   
EMAIL_HOST_USER = 'another_email'   # We're sending the notification from here so we need HOST, PW, PORT
EMAIL_HOST_PASSWORD = 'my_password'
EMAIL_PORT = 25
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'myemail'

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'standard': {
            'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
        },
    },
    'handlers': {
        'default': {
            'level':'DEBUG',
            'class':'logging.handlers.RotatingFileHandler',
            'filename': SITE_ROOT + '\\logfile.log',
            'maxBytes': 1024*1024*5, # 5 MB
            'backupCount': 5,
            'formatter':'standard',
        },  
        'request_handler': {
            'level':'DEBUG',
            'class':'logging.handlers.RotatingFileHandler',
            'filename':  SITE_ROOT + '\\django_request.log',
            'maxBytes': 1024*1024*5, # 5 MB
            'backupCount': 5,
            'formatter':'standard',
        },
        'mail_admins': {
            'level': 'DEBUG',
            'class': 'django.utils.log.AdminEmailHandler',
    },
 },
    'loggers': {
        '': {
                'handlers': ['mail_admins', 'default'],
                'level': 'DEBUG',
                'propagate': True
        },
        'django.request': {
                'handlers': ['request_handler'],
                'level': 'DEBUG',
                'propagate': False
        },
        'django': {
                'handlers': ['request_handler', 'default', 'mail_admins'],
                'level': 'DEBUG',
                'propagate': True,
        },
    }
}
1

There are 1 answers

0
pymat On BEST ANSWER

I managed to locate the issue myself. It was related to my settings.py file:

ADMINS = (
  ('My name', '[email protected]'),
)

Commenting out this code brought the speed back of the manage.py command to normal again. I'm not too sure the reason why other than perhaps a notification was trying to send/communicate with this address, and since I'm behind a proxy, the process was taking minutes longer. Perhaps someone can provide a more precise reason for this.