由于empty_like方法已具有文档字符串而导致的内部服务器错误

时间:2019-02-11 06:53:13

标签: django python-3.x numpy django-rest-framework

目前我正面临一个问题。好的,让我分享一下。

我已将该项目部署到服务器(apache2)中,该服务器工作正常并且所有操作均成功完成。但是突然之间,登录时基本上得到Internal server error。下载日志后,它显示RuntimeError: empty_like method already has a docstring。当我再次重新启动服务器时,它再次可以正常工作。但是我认为这需要一个永久的解决方案。我也想分享日志的完整记录。

  Internal Server Error: /
  Traceback (most recent call last):
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/django/core/handlers/exception.py", line 35, in inner
      response = get_response(request)
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/django/core/handlers/base.py", line 113, in _get_response
      resolver_match = resolver.resolve(request.path_info)
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/django/urls/resolvers.py", line 498, in resolve
      for pattern in self.url_patterns:
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/django/utils/functional.py", line 36, in __get__
      res = instance.__dict__[self.name] = self.func(instance)
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/django/urls/resolvers.py", line 540, in url_patterns
      patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/django/utils/functional.py", line 36, in __get__
      res = instance.__dict__[self.name] = self.func(instance)
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/django/urls/resolvers.py", line 533, in urlconf_module
      return import_module(self.urlconf_name)
    File "/opt/python/ai_rest_env/lib/python3.5/importlib/__init__.py", line 126, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 986, in _gcd_import
    File "<frozen importlib._bootstrap>", line 969, in _find_and_load
    File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 665, in exec_module
    File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
    File "/opt/python/my_project/my_project/urls.py", line 19, in <module>
      from apps.app_1 import urls as app_1_urls
    File "/opt/python/my_project/apps/app_1/urls.py", line 19, in <module>
      from .controller import main_controller
    File "/opt/python/my_project/apps/app_1/controller/main_controller.py", line 11, in <module>
      from .icebreaking_controller import IceBreakingController
    File "/opt/python/my_project/apps/app_1/controller/icebreaking_controller.py", line 1, in <module>
      from .base_controller import BaseController
    File "/opt/python/my_project/apps/app_1/controller/base_controller.py", line 4, in <module>
      from ..ai_model_handler.answer_validator import AnswerValidator
    File "/opt/python/my_project/apps/app_1/ai_model_handler/answer_validator.py", line 6, in <module>
      from ..ai_models.multiclass_cnn.multiclass_cnn_request import MultiClassCNNRequest
    File "/opt/python/my_project/apps/app_1/ai_models/multiclass_cnn/multiclass_cnn_request.py", line 11, in <module>
      import tensorflow as tf
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/tensorflow/__init__.py", line 22, in <module>
      from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 47, in <module>
      import numpy as np
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/numpy/__init__.py", line 142, in <module>
      from . import core
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/numpy/core/__init__.py", line 16, in <module>
      from . import multiarray
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/numpy/core/multiarray.py", line 70, in <module>
      def empty_like(prototype, dtype=None, order=None, subok=None):
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/numpy/core/overrides.py", line 240, in decorator
      docs_from_dispatcher=docs_from_dispatcher)(implementation)
    File "/opt/python/ai_rest_env/lib/python3.5/site-packages/numpy/core/overrides.py", line 204, in decorator
      add_docstring(implementation, dispatcher.__doc__)
  RuntimeError: empty_like method already has a docstring

技术:python3.6 django 2.0.7

1 个答案:

答案 0 :(得分:1)

我根据问题注释的建议进行了一些研发工作,其中包含用于{em> wsgi 配置的single-interpreter=true问题。 从文档中找到了建议 https://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIApplicationGroup.html?highlight=WSGIApplicationGroup#wsgiapplicationgroup

来自文档。

  

WSGIApplicationGroup伪指令可用于指定WSGI应用程序或WSGI应用程序集属于哪个应用程序组。同一应用程序组中的所有WSGI应用程序都将在处理请求的流程的同一Python子解释器的上下文中执行。

在我看来,这与single-interpreter=true有关。

并通过添加以下行来配置mod_wsgi

WSGIApplicationGroup %{GLOBAL}

我观察到上个月使用此配置的服务器日志。 服务器正在运行,没有出现以上错误。