Issue Details (XML | Word | Printable)

Key: MODPYTHON-10
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Graham Dumpleton
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
mod_python

Continual reloading of modules

Created: 28/Jan/05 05:58 PM   Updated: 05/Mar/06 01:36 PM
Component/s: None
Affects Version/s: 3.1.3
Fix Version/s: 3.2.7

Time Tracking:
Not Specified

Resolution Date: 30/Apr/05 03:47 PM


 Description  « Hide
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.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Nicolas Lehuen added a comment - 30/Apr/05 03:47 PM
Resolved along with MODPYTHON-9.