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 2006/10/08 12:06:19 UTC

[jira] Resolved: (MODPYTHON-180) publisher wrongly generating warning that there is 'nothing to publish'

     [ http://issues.apache.org/jira/browse/MODPYTHON-180?page=all ]

Graham Dumpleton resolved MODPYTHON-180.
----------------------------------------

    Resolution: Fixed

Added a new internal (ie., not intended to be used by public), member called _bytes_queued to the request object which tracks number of bytes of data written using req.write() or req.sendfile(). Use this instead of req.bytes_sent, which doesn't take into consideration data still buffered and not processed by any output filters.

Couldn't see any other way of doing it if we want a warning for case when nothing output by the handler. Note that one could still have cases where the publisher doesn't produce anything, but did set some output header which was then interpreted by an output filter causing the output filter to produce some actual content for the response.

Being notionally a private member we can always undo this later if we decide to get rid of the warning altogether or we work out a better way of doing it.

> publisher wrongly generating warning that there is 'nothing to publish'
> -----------------------------------------------------------------------
>
>                 Key: MODPYTHON-180
>                 URL: http://issues.apache.org/jira/browse/MODPYTHON-180
>             Project: mod_python
>          Issue Type: Bug
>          Components: publisher
>    Affects Versions: 3.3
>            Reporter: Graham Dumpleton
>         Assigned To: Graham Dumpleton
>             Fix For: 3.3
>
>
> Publisher handler contains the code:
>     # we log a message if nothing was published, it helps with debugging
>     if (not published) and (req.bytes_sent==0) and (req.next is None):
>         log=int(req.get_config().get("PythonDebug", 0))
>         if log:
>             req.log_error("mod_python.publisher: nothing to publish.")
> The idea is that if the publisher didn't generate any output and simply returned None, that a warning would be generated which might be noticed by a developer and thus be helpful to debugging problems.
> Problem is that "req.bytes_sent" is only actually non zero when data is flushed and actually written back to the client by Apache. It does not take into consideration any buffered data.
> In other words, if "req.write()" is used but second optional argument is always being set to 0 indicating that data should not be flushed, then publisher will wrongly say nothing actually got published.
> Because the PSP classes are no longer flushing data so that output filters like "CONTENT_LENGTH" will work, this will mean you will get this warning all the time when using code like:
>   from mod_python import apache, psp
>   def index(req):
>       page = psp.PSP(req, 'echo.psp')
>       page.run()
> Question is, is there a way to determine from Apache that there is buffered data. We don't really want to be adding another special flag in the mod_python request wrapper like req._content_type_set do we???

-- 
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