You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by "Graham Dumpleton (JIRA)" <ji...@apache.org> on 2005/03/20 11:10:23 UTC

[jira] Created: (MODPYTHON-37) Add apache.register_cleanup().

Add apache.register_cleanup().
------------------------------

         Key: MODPYTHON-37
         URL: http://issues.apache.org/jira/browse/MODPYTHON-37
     Project: mod_python
        Type: New Feature
  Components: core  
    Versions: 3.1.4    
    Reporter: Graham Dumpleton
    Priority: Minor


The only way to register cleanup methods to be executed upon child termination
is through req.server.register_cleanup(). Since the cleanup method isn't specific
to a request, it seems that there should also be an apache.register_cleanup(). This
would allow cleanup function registration upon child termination to be done from
a module imported using the PythonImport directive.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Updated: (MODPYTHON-37) Add apache.register_cleanup().

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-37?page=all ]

Graham Dumpleton updated MODPYTHON-37:
--------------------------------------

    Attachment: register_cleanup.diff.txt

Added diff as attachment that implements desired functionality. Diff was against the
latest code in subversion repository.

> Add apache.register_cleanup().
> ------------------------------
>
>          Key: MODPYTHON-37
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-37
>      Project: mod_python
>         Type: New Feature
>   Components: core
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>     Priority: Minor
>  Attachments: register_cleanup.diff.txt
>
> The only way to register cleanup methods to be executed upon child termination
> is through req.server.register_cleanup(). Since the cleanup method isn't specific
> to a request, it seems that there should also be an apache.register_cleanup(). This
> would allow cleanup function registration upon child termination to be done from
> a module imported using the PythonImport directive.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (MODPYTHON-37) Add apache.register_cleanup().

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-37?page=all ]
     
Graham Dumpleton closed MODPYTHON-37:
-------------------------------------


Although closing this issue, should be noted that both apache.register_cleanup() and req.server.register_cleanup() may need to be deprecated and removed. This is because the only mechanism for having a cleanup function run on server shutdown is error prone as it invokes stuff from a signal handler. See MODPYTHON-109.

> Add apache.register_cleanup().
> ------------------------------
>
>          Key: MODPYTHON-37
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-37
>      Project: mod_python
>         Type: New Feature
>   Components: core
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>     Priority: Minor
>      Fix For: 3.2.7
>  Attachments: register_cleanup.diff.txt
>
> The only way to register cleanup methods to be executed upon child termination
> is through req.server.register_cleanup(). Since the cleanup method isn't specific
> to a request, it seems that there should also be an apache.register_cleanup(). This
> would allow cleanup function registration upon child termination to be done from
> a module imported using the PythonImport directive.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Re: [jira] Resolved: (MODPYTHON-37) Add apache.register_cleanup().

Posted by Nicolas Lehuen <ni...@gmail.com>.
OK, I've made the modification.

Regards,
Nicolas

2005/8/6, Graham Dumpleton <gr...@dscpl.com.au>:
> 
> You might want to change "args" in the apache.register_cleanup()
> function to be "data", to match existing documentation for other similar
> methods. Use of "args" gives an impression that it is multiple values in
> a list/tuple whereas in practice is a single value of any type. I used
> "data" in my updated version in JIRA followup but probably didn't make
> it clear enough in associated comments that the parameter name should
> be changed as well as the default value. :-)
> 
> Ie., use:
> 
> def register_cleanup(handler,data=None):
> _apache.register_cleanup(_interpreter,_server,handler,data)
> 
> 
> On 06/08/2005, at 7:17 PM, Nicolas Lehuen (JIRA) wrote:
> 
> > [ http://issues.apache.org/jira/browse/MODPYTHON-37?page=all ]
> >
> > Nicolas Lehuen resolved MODPYTHON-37:
> > -------------------------------------
> >
> > Fix Version: 3.2.0
> > Resolution: Fixed
> >
> > I have integrated Graham's patch (with data=None instead of data=()).
> > I have also added a unit test to check whether the new
> > apache.register_cleanup funciton works correctly? I ran the unit test
> > and everything seems OK, there is no regression and the new function
> > is OK.
> >
> >> Add apache.register_cleanup().
> >> ------------------------------
> >>
> >> Key: MODPYTHON-37
> >> URL: http://issues.apache.org/jira/browse/MODPYTHON-37
> >> Project: mod_python
> >> Type: New Feature
> >> Components: core
> >> Versions: 3.1.4
> >> Reporter: Graham Dumpleton
> >> Priority: Minor
> >> Fix For: 3.2.0
> >> Attachments: register_cleanup.diff.txt
> >>
> >> The only way to register cleanup methods to be executed upon child
> >> termination
> >> is through req.server.register_cleanup(). Since the cleanup method
> >> isn't specific
> >> to a request, it seems that there should also be an
> >> apache.register_cleanup(). This
> >> would allow cleanup function registration upon child termination to
> >> be done from
> >> a module imported using the PythonImport directive.
> >
> > --
> > This message is automatically generated by JIRA.
> > -
> > If you think it was sent incorrectly contact one of the administrators:
> > http://issues.apache.org/jira/secure/Administrators.jspa
> > -
> > For more information on JIRA, see:
> > http://www.atlassian.com/software/jira
> 
>

Re: [jira] Resolved: (MODPYTHON-37) Add apache.register_cleanup().

Posted by Graham Dumpleton <gr...@dscpl.com.au>.
You might want to change "args" in the apache.register_cleanup()
function to be "data", to match existing documentation for other similar
methods. Use of "args" gives an impression that it is multiple values in
a list/tuple whereas in practice is a single value of any type. I used
"data" in my updated version in JIRA followup but probably didn't make
it clear enough in associated comments that the parameter name should
be changed as well as the default value. :-)

Ie., use:

def register_cleanup(handler,data=None):
     _apache.register_cleanup(_interpreter,_server,handler,data)


On 06/08/2005, at 7:17 PM, Nicolas Lehuen (JIRA) wrote:

>      [ http://issues.apache.org/jira/browse/MODPYTHON-37?page=all ]
>
> Nicolas Lehuen resolved MODPYTHON-37:
> -------------------------------------
>
>     Fix Version: 3.2.0
>      Resolution: Fixed
>
> I have integrated Graham's patch (with data=None instead of data=()). 
> I have also added a unit test to check whether the new 
> apache.register_cleanup funciton works correctly? I ran the unit test 
> and everything seems OK, there is no regression and the new function 
> is OK.
>
>> Add apache.register_cleanup().
>> ------------------------------
>>
>>          Key: MODPYTHON-37
>>          URL: http://issues.apache.org/jira/browse/MODPYTHON-37
>>      Project: mod_python
>>         Type: New Feature
>>   Components: core
>>     Versions: 3.1.4
>>     Reporter: Graham Dumpleton
>>     Priority: Minor
>>      Fix For: 3.2.0
>>  Attachments: register_cleanup.diff.txt
>>
>> The only way to register cleanup methods to be executed upon child 
>> termination
>> is through req.server.register_cleanup(). Since the cleanup method 
>> isn't specific
>> to a request, it seems that there should also be an 
>> apache.register_cleanup(). This
>> would allow cleanup function registration upon child termination to 
>> be done from
>> a module imported using the PythonImport directive.
>
> -- 
> This message is automatically generated by JIRA.
> -
> If you think it was sent incorrectly contact one of the administrators:
>    http://issues.apache.org/jira/secure/Administrators.jspa
> -
> For more information on JIRA, see:
>    http://www.atlassian.com/software/jira


[jira] Resolved: (MODPYTHON-37) Add apache.register_cleanup().

Posted by "Nicolas Lehuen (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-37?page=all ]
     
Nicolas Lehuen resolved MODPYTHON-37:
-------------------------------------

    Fix Version: 3.2.0
     Resolution: Fixed

I have integrated Graham's patch (with data=None instead of data=()). I have also added a unit test to check whether the new apache.register_cleanup funciton works correctly? I ran the unit test and everything seems OK, there is no regression and the new function is OK.

> Add apache.register_cleanup().
> ------------------------------
>
>          Key: MODPYTHON-37
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-37
>      Project: mod_python
>         Type: New Feature
>   Components: core
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>     Priority: Minor
>      Fix For: 3.2.0
>  Attachments: register_cleanup.diff.txt
>
> The only way to register cleanup methods to be executed upon child termination
> is through req.server.register_cleanup(). Since the cleanup method isn't specific
> to a request, it seems that there should also be an apache.register_cleanup(). This
> would allow cleanup function registration upon child termination to be done from
> a module imported using the PythonImport directive.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MODPYTHON-37) Add apache.register_cleanup().

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/MODPYTHON-37?page=comments#action_12317831 ] 

Graham Dumpleton commented on MODPYTHON-37:
-------------------------------------------

Note, attached diff has minor mistake. See following excerpt from mailing
list note this as well as a bit of documentation.

> I need to know what all parameters apache.register_cleanup() is expecting.

Just like you had called req.register_cleanup() except that cleanup
handler is called on server shutdown like req.server.register_cleanup().

 register_cleanup(callable[, data])

   Registers a cleanup. Argument callable can be any callable object, the
   optional argument data can be any object (default is  None). At Apache
   child process termination, callable will be called with one argument, data.

   If errors are encountered during cleanup processing, they should be in
   error log.

Note that I have actually made a minor mistake in the code. In apache.py,
the prototype should be:

  def register_cleanup(handler,data=None):
      _apache.register_cleanup(_interpreter,_server,handler,data)

I used "args=()" which isn't technically correct but only in as much as
I used "()" instead of "None". I was thinking you could supply a tuple of
arguments whereas you can actually only supply a single argument. What I
did wouldn't have stopped it working though.

Anyway, you should be able to do:

  def shutdown1():
      apache.log_error("shutdown1")

  apache.register_cleanup(shutdown1)

  def shutdown2(data):
      apache.log_error("shutdown2 %r"%data)

  apache.register_cleanup(shutdown2,"data")


> Add apache.register_cleanup().
> ------------------------------
>
>          Key: MODPYTHON-37
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-37
>      Project: mod_python
>         Type: New Feature
>   Components: core
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>     Priority: Minor
>  Attachments: register_cleanup.diff.txt
>
> The only way to register cleanup methods to be executed upon child termination
> is through req.server.register_cleanup(). Since the cleanup method isn't specific
> to a request, it seems that there should also be an apache.register_cleanup(). This
> would allow cleanup function registration upon child termination to be done from
> a module imported using the PythonImport directive.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MODPYTHON-37) Add apache.register_cleanup().

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-37?page=comments#action_61574 ]
     
Graham Dumpleton commented on MODPYTHON-37:
-------------------------------------------

This may not be straightforward. See comments from FAQ entry:

  http://www.modpython.org/FAQ/faqw.py?req=show&file=faq03.011.htp

> Add apache.register_cleanup().
> ------------------------------
>
>          Key: MODPYTHON-37
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-37
>      Project: mod_python
>         Type: New Feature
>   Components: core
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>     Priority: Minor

>
> The only way to register cleanup methods to be executed upon child termination
> is through req.server.register_cleanup(). Since the cleanup method isn't specific
> to a request, it seems that there should also be an apache.register_cleanup(). This
> would allow cleanup function registration upon child termination to be done from
> a module imported using the PythonImport directive.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira