Uploaded image for project: 'mod_python'
  1. mod_python
  2. MODPYTHON-113

PythonImport should use apache.import_module() and not PyImport_ImportModule().

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1.4, 3.2.7
    • 3.3.1
    • core
    • None

    Description

      When the "PythonImport" directive is used, mod_python uses the "PyImport_ImportModule()" function to import the specified module. If that same module is later imported using the "apache.import_module()" function, it will be reloaded a second time even though the Python module file hadn't changed and even if "PythonAutoReload" is set to "Off".

      This reloading can cause problems if the module when loaded using PythonImport had setup resources such as database connections etc. This is because "apache.import_module()" will effectively throw away the existing values
      and replace them. This can be an issue if the resources aren't deleted properly and hold open stuff like socket connections with those connections no longer being accessible or useable.

      The basic problem here is the mixing of standard Python import mechanism and any system implemented by mod_python. The best solution now and in the future, would be for the "PythonImport" directive to use the "apache.import_module()" function to import any modules. That way it would be ensured they always work together properly and not against each other.

      Note that this problem was previously catalogued as ISSUE 17 on my list of mod_python module importing problems. This list of problems can be found at:

      http://www.dscpl.com.au/articles/modpython-003.html

      Attachments

        1. MP113_20060316_grahamd_1.diff
          4 kB
          Graham Phillip Dumpleton

        Activity

          People

            grahamd Graham Phillip Dumpleton
            grahamd Graham Phillip Dumpleton
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment