On Wednesday 05 December 2001 13:46, Aaron Held wrote:
> Thanks for all the great pointers.
>
> I just got a short deadline extension for this milestone, so
> hopefully I'll have time to create something using your advice
> rather then lots of sockets
>
> Can I pass a reference to the application rather then subclass it?
> like
>
> > app = trans.application()
> > from threading import Thread
> > t = Thread(target=updater._threadTargetMethod, args=(app))

Yeah that would work as well.  My point about joining the thread was 
that if you need to shutdown webkit before the thread has finished 
its work you'll need some way of telling it to abort.   Here's a way 
to make sure that it exits automatically:

class Processor:
   def __init__(self, app, [other args]):
       self._app = app
       self._thread = Thread(target=self.run)

   def start(self)
       self._thread.start()

   def run(self):
       while self._app.running:
           [do something]
   
# ... in your servlet

from Processor import Processor
if [some GET/POST val]:
   app = trans.application()
   app._processor = p = Processor(app)
   p.start()


Without something like this you'd have to do an unclean shutdown of 
webkit with SIGKILL instead of SIGTERM if the processor hadn't 
finished, which might leave things in the wrong state.

> ----- Original Message -----
> From: "Tavis Rudd" <[EMAIL PROTECTED]>
> To: "Aaron Held" <[EMAIL PROTECTED]>; "Geoffrey Talvola"
> <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]> Sent: Wednesday, December
> 05, 2001 5:44 PM
> Subject: Re: [Webware-discuss] Detach a process from a page.
>
> > On Wednesday 05 December 2001 13:18, Aaron Held wrote:
> > > If I spawn out a thread from the servlet won't it still be
> > > attached to the servlet?
> >
> > It'll be attached to the WebKit process, but as a thread is an
> > object in Python you can just assign it as an attribute of the
> > Application class.
> >
> > app = trans.application()
> > from threading import Thread
> > t = Thread(target=app._threadTargetMethod)
> > app._myThread = t
> > t.start()
> > # you could substitue app with a module here
> >
> > This way the thread isn't attached to a particular servlet.  You
> > could encapsulate all this as a method of your application class.
> > Unfortunately, in the existing WebKit it isn't easy to use your
> > own subclass of Application.
> >
> > Of course you'll need to make sure it is joined properly when
> > it's finished doing its thing.  There are several ways of doing
> > that. Application.shutDown is a logical place, but again
> > Application subclassing isn't easy.  Maybe TaskKit handles this,
> > I'm not sure...

_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to