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

Continual reloading of modules

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.3
    • Fix Version/s: 3.2.7
    • Component/s: None
    • Labels:
      None

      Description

      From mailing list post.

      Continual reloading of modules
      ------------------------------

      Create a subdirectory called "publisher". In that directory create a
      ".htaccess" file containing:

      SetHandler python-program
      PythonHandler mod_python.publisher
      PythonDebug On

      Now create two subdirectories "subdir-1" and "subdir-1". In both of these
      subdirectories create an "index.py" file which contains:

      import os
      def index():
      return os.getpid(),_file_

      Restart Apache to clear any cached modules and then cycle between the URLs
      corresponding to the two subdirectories. In my case this is:

      /~grahamd/publisher/subdir-1
      /~grahamd/publisher/subdir-2
      /~grahamd/publisher/subdir-1
      /~grahamd/publisher/subdir-2
      ...

      The output for each page was in turn:

      (462, '/Users/grahamd/Sites/publisher/subdir-1/index.py')
      (462, '/Users/grahamd/Sites/publisher/subdir-2/index.py')
      (462, '/Users/grahamd/Sites/publisher/subdir-1/index.pyc')
      (462, '/Users/grahamd/Sites/publisher/subdir-2/index.pyc')
      ...

      If you look at the Apache error log file you will see something like:

      [Tue Jan 25 09:03:45 2005] [notice] mod_python: Creating 32 session mutexes
      based on 4 max processes and 25 max threads.
      [Tue Jan 25 09:03:45 2005] [notice] Apache/2.0.51 (Unix) mod_python/3.1.3
      Python/2.3 configured – resuming normal operations

      [Tue Jan 25 09:04:02 2005] [notice] mod_python: (Re)importing module
      'mod_python.publisher'
      [Tue Jan 25 09:04:02 2005] [notice] mod_python: (Re)importing module 'index'
      with path set to '['/Users/grahamd/Sites/publisher/subdir-1']'
      [Tue Jan 25 09:04:16 2005] [notice] mod_python: (Re)importing module 'index'
      with path set to '['/Users/grahamd/Sites/publisher/subdir-2']'
      [Tue Jan 25 09:04:26 2005] [notice] mod_python: (Re)importing module 'index'
      with path set to '['/Users/grahamd/Sites/publisher/subdir-1']'
      [Tue Jan 25 09:04:40 2005] [notice] mod_python: (Re)importing module 'index'
      with path set to '['/Users/grahamd/Sites/publisher/subdir-2']'

      You will see how as one cycles between the two URLs corresponding to the
      modules, that the modules are reimported everytime.

      Note that I ensured that only one Apache server process was initially
      started so that all requests served by same process. One can also see this
      is the response, which includes the process ID of the server process.

      Overall what is returned is correct, but it isn't efficient because each
      request is triggering a module import.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              grahamd Graham Phillip Dumpleton
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: