[mod_python] Using Twisted inside mod_python

jarrod roberson jarrod.roberson at gmail.com
Fri May 6 11:59:47 EDT 2005

On 5/6/05, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> jarrod roberson wrote ..
> > On 5/5/05, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> > > Question to the original poster. Have you added sufficient debug into
> > each
> > > step of the internals of that call so as to know precisely when the 
> code
> > > seems to block?
> >
> >
> > that call basically walks a list filters out some items and builds 
> another
> > list to return
> > I have done alot of basic debugging and the problem is it just hangs 
> apache
> > and I have to kill it.
> > Thus it doesn't print anything out because it doesn't shut down 
> correctly.
> Is your debug using "print" or "apache.log_error()" from mod_python. 

it is apache.log_error()

If the
> latter, it should be logged to Apache log straight away and adding 
> sufficient
> debugging should be able to identify place it stops if it reliably stops 
> in the
> same place. Is there any evidence it stops at the same place? 

yep same place req.write() 

Does Apache
> process go to idle, or does it look to be stuck in a tight loop and 
> hogging
> all the CPU? 

seems that only that req hangs, I enabled the apache server-status mod and 
it seems that
all the req threads go into a (W)ait mode when that call happens and never 
return :-(

Depending on what platform you are using, does use of ktrace,
> ptrace, strace or truss, indicate that Apache process is stuck within 
> certain
> system calls? These tools should be able to pointed at the process using 
> its
> pid. Tools on Mac OS X are good for this sort of debugging as can show 
> where
> different threads are and whether they are waiting on locks etc.

I am using OSX 10.4 so I will look into what it can do, I just got my 
PowerBook in March so that is still a learning curve.

> Do you know that a separate thread can't call into Twisted
> > > unless it uses appropriate mechanisms?
> >
> >
> > I do now, what I don't know is what "appropriate mechanisms" is 
> specifically
> I don't use Twisted, but based on recent comp.lang.python post, there is a
> call "callFromThread". Example on the new group was:
> import time
> from twisted.internet import reactor
> def shutdown():
> time.sleep(3)
> print "stopping"
> reactor.callFromThread(reactor .stop)
> reactor.callInThread(shutdown)
> reactor.run()
> Don't know much more than that.
> Graham

Awesome, thanks for the advice I will go and try all that stuff!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20050506/0c7a12cb/attachment-0001.html

More information about the Mod_python mailing list