Issue Details (XML | Word | Printable)

Key: MODPYTHON-113
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Graham Dumpleton
Reporter: Graham Dumpleton
Votes: 0
Watchers: 0
Operations

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

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

Created: 26/Jan/06 04:07 PM   Updated: 05/Apr/07 11:37 AM
Component/s: core
Affects Version/s: 3.1.4, 3.2.7
Fix Version/s: 3.3.1

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works MP113_20060316_grahamd_1.diff 2006-03-16 12:44 PM Graham Dumpleton 4 kB

Resolution Date: 17/Mar/06 12:16 PM
Labels:


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

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Graham Dumpleton made changes - 11/Mar/06 08:26 AM
Field Original Value New Value
Assignee Graham Dumpleton [ grahamd ]
Graham Dumpleton made changes - 11/Mar/06 08:26 AM
Status Open [ 1 ] In Progress [ 3 ]
Graham Dumpleton added a comment - 16/Mar/06 12:44 PM
Attached "MP113_20060316_grahamd_1.diff" containing proposed changes. This also includes changes to implement MODPYTHON-118.

The problem covered by this issue needs to be addressed, but changes for MODPYTHON-118 are optional and can be left out if anyone objects.

Feedback appreciated.

Graham Dumpleton made changes - 16/Mar/06 12:44 PM
Attachment MP113_20060316_grahamd_1.diff [ 12324247 ]
Repository Revision Date User Message
ASF #386524 Fri Mar 17 04:14:22 UTC 2006 grahamd PythonImport directive now uses apache.import_module() to import modules
to avoid issues with modules being loaded multiple times. (MODPYTHON-113)
PythonImport directive now allows function within module to be optionally
specified where function is called after module has been successfully
imported. (MODPYTHON-118)
Files Changed
MODIFY /httpd/mod_python/trunk/test/htdocs/tests.py
MODIFY /httpd/mod_python/trunk/Doc/modpython5.tex
MODIFY /httpd/mod_python/trunk/test/test.py
MODIFY /httpd/mod_python/trunk/src/mod_python.c
ADD /httpd/mod_python/trunk/test/htdocs/dummymodule.py
MODIFY /httpd/mod_python/trunk/Doc/appendixc.tex
MODIFY /httpd/mod_python/trunk/lib/python/mod_python/apache.py

Graham Dumpleton made changes - 17/Mar/06 12:16 PM
Resolution Fixed [ 1 ]
Fix Version/s 3.3 [ 12310101 ]
Status In Progress [ 3 ] Resolved [ 5 ]
Graham Dumpleton made changes - 05/Apr/07 11:37 AM
Status Resolved [ 5 ] Closed [ 6 ]