On 3/30/06, Robert Brewer <fumanchu amor.org> wrote:
> Kevin Dangoor wrote:
> On 3/29/06, Rob Cowie <cowie.rob gmail.com> wrote:
> > > Is this enough to kill the thread? Currently,
when
> > > I kill cherrypy at the command line with
cmd-C,
> > > I am not returned to a shell prompt as a
thread
> > > is still running.
> >
> > I believe that thread will die when the timer
fires.
>
> It shouldn't wait for that. The Worker's curthread
attribute is actually a threading.Timer, which uses a
threading.Event with a threading.Condition object (whew!).
Anyway, Condition.wait sleeps for small periods of time, and
can be interrupted. From the comments in threading.py:
>
> # Balancing act: We can't afford a pure busy
loop, so we
> # have to sleep; but if we sleep the whole timeout
time,
> # we'll be unresponsive. The scheme here sleeps
very
> # little at first, longer as time goes on, but
never longer
> # than 20 times per second (or the timeout time
remaining).
>
> So the Worker's thread should die within 1/20 of a
second at most.
Interesting to know that it polls 20 times a second *at a
minimum*. I
never would've guess that it's that responsive to
cancellations. One
probably wouldn't want too many of those threads going at
once! (Which
is where a sched-based scheduler comes in handier.)
Kevin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|