[mod_python] Profiling mod_python with callables?

Webb Sprague webb.sprague at gmail.com
Mon Sep 24 01:35:26 EDT 2007


On 9/23/07, Graham Dumpleton <graham.dumpleton at gmail.com> wrote:
> Use:
>
>   return cProfile.runctx('ListObjects()', globals(), locals(),
> filename='/tmp/ListObjectProf')

This errors out:

Traceback (most recent call last):

  File "/usr/lib64/python2.5/site-packages/mod_python/importer.py",
line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib64/python2.5/site-packages/mod_python/importer.py",
line 1229, in _process_target
    result = _execute_target(config, req, object, arg)

  File "/usr/lib64/python2.5/site-packages/mod_python/importer.py",
line 1128, in _execute_target
    result = object(arg)

  File "/usr/lib64/python2.5/site-packages/mod_python/publisher.py",
line 213, in handler
    published = publish_object(req, object)

  File "/usr/lib64/python2.5/site-packages/mod_python/publisher.py",
line 425, in publish_object
    return publish_object(req,util.apply_fs_data(object, req.form, req=req))

  File "/usr/lib64/python2.5/site-packages/mod_python/util.py", line
554, in apply_fs_data
    return object(**args)

  File "/var/www/localhost/htdocs/larry/lc.py", line 85, in ListObjectsProfile
    return cProfile.runctx('ListObjects()', globals(), locals(),
filename='/tmp/ListObjectProf')

  File "/usr/lib64/python2.5/cProfile.py", line 49, in runctx
    prof = prof.runctx(statement, globals, locals)

  File "/usr/lib64/python2.5/cProfile.py", line 140, in runctx
    exec cmd in globals, locals

  File "<string>", line 1, in <module>

TypeError: __call__() takes exactly 2 arguments (1 given)

TIA ;)
-W
>
> instead.
>
> Graham
>
> On 24/09/2007, Webb Sprague <webb.sprague at gmail.com> wrote:
> > (Sorry meant to reply to list.)
> >
> > Here is the error from http://blah/larry/lc/ListObjectsProfile, minus
> > some personal stuff ;)
> >
> > MOD_PYTHON ERROR
> >
> > ProcessId:      31202
> >
> > URI:            '/larry/lc/ListObjectsProfile'
> > Location:       None
> > PathInfo:       '/ListObjectsProfile'
> >
> > Phase:          'PythonHandler'
> > Handler:        'mod_python.publisher'
> >
> > Traceback (most recent call last):
> >
> >   File "/usr/lib64/python2.5/site-packages/mod_python/importer.py",
> > line 1537, in HandlerDispatch
> >     default=default_handler, arg=req, silent=hlist.silent)
> >
> >   File "/usr/lib64/python2.5/site-packages/mod_python/importer.py",
> > line 1229, in _process_target
> >     result = _execute_target(config, req, object, arg)
> >
> >   File "/usr/lib64/python2.5/site-packages/mod_python/importer.py",
> > line 1128, in _execute_target
> >     result = object(arg)
> >
> >   File "/usr/lib64/python2.5/site-packages/mod_python/publisher.py",
> > line 213, in handler
> >     published = publish_object(req, object)
> >
> >   File "/usr/lib64/python2.5/site-packages/mod_python/publisher.py",
> > line 425, in publish_object
> >     return publish_object(req,util.apply_fs_data(object, req.form, req=req))
> >
> >   File "/usr/lib64/python2.5/site-packages/mod_python/util.py", line
> > 554, in apply_fs_data
> >     return object(**args)
> >
> >   File "/var/www/localhost/htdocs/larry/lc.py", line 82, in ListObjectsProfile
> >     return cProfile.run('ListObjects', '/tmp/ListObjectProf')
> >
> >   File "/usr/lib64/python2.5/cProfile.py", line 29, in run
> >     prof = prof.run(statement)
> >
> >   File "/usr/lib64/python2.5/cProfile.py", line 135, in run
> >     return self.runctx(cmd, dict, dict)
> >
> >   File "/usr/lib64/python2.5/cProfile.py", line 140, in runctx
> >     exec cmd in globals, locals
> >
> >   File "<string>", line 1, in <module>
> >
> > NameError: name 'ListObjects' is not defined
> >
> >
> > On 9/23/07, Graham Dumpleton <graham.dumpleton at gmail.com> wrote:
> > > Bouncing this back to list as reply-all not used.
> > >
> > > In what way does that not actually work?
> > >
> > > Graham
> > >
> > > On 24/09/2007, Webb Sprague <webb.sprague at gmail.com> wrote:
> > > > Well, Graham, as usual you are an extremely prompt and helpful
> > > > correspondent... but is there any way to do something like the
> > > > following, which would work per call, giving a regular display and
> > > > writing to a log (if it worked at all)? --
> > > >
> > > >
> > > > ListObjects = LcPageObjects.LcList(lcdb=lcdb,
> > > >                                    navTemplate=LARRYTEMPLATEDIR +
> > > > '/Application.tmpl',
> > > >                                    objectListTemplate =
> > > > LARRYTEMPLATEDIR + '/ObjectList.tmpl',
> > > >                                    title='LAR-E Object List')
> > > > def ListObjectsProfile():
> > > >     global ListObjects
> > > >     return cProfile.run('ListObjects()', '/tmp/ListObjectProf')
> > > >
> > > > Tx
> > > >
> > > > On 9/23/07, Graham Dumpleton <