Django manage.py命令挂起

时间:2017-08-31 10:10:28

标签: python-3.x manage.py django-1.11

之前完全正常的事情,已经放弃了我。当使用如下所示的任何类型的manage.py命令时,我会看到Performing system checks...

python manage.py runserver 

python manage.py makemigrations

大约30-60秒的悬挂后,我得到:

System check identified no issues (0 silenced).

哪个挂起,挂起并挂起...然后大约6分钟后,我再次看到正常的Quit the server with CONTROL-C 为了调试这个问题,我甚至试图评论我的应用程序和中间件,以及关闭我的PY上的其他应用程序并执行重启,仍然没有变化。我还需要注意什么呢?这似乎太长了。

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 个答案:

答案 0 :(得分:0)

我设法自己找到了这个问题。它与我的 settings.py 文件相关:

ADMINS = (
  ('My name', 'myemail@domain.com'),
)

注释掉这段代码会使manage.py命令的速度再次恢复正常。我不太确定为什么除了通知之外还试图发送/与此地址通信,并且因为我在代理后面,这个过程花费的时间更长。也许某人可以提供更准确的理由。