[TransWarp] Stopping peak.running.scheduler.UntwistedReactor
alexander smishlajev
alex at ank-sia.com
Fri Jul 11 09:39:40 EDT 2003
Phillip J. Eby wrote:
>
>> I have an application, that uses
>> peak.running.scheduler.UntwistedReactor. There are some readers and
>> writers registered in this reactor, but there could be a situation,
>> when no more readers, writer and laters left - so there is nothing to
>> proceed. And this is the point, reactor must be terminated, I suppose...
>
> How does it happen that you end up with no more readers or writers? I'm
> curious, because in most circumstances, at least one reader will be some
> kind of server listening, so why would it be terminated?
we have an application components that may be run either from
application server (within it's main loop) or as a standalone
application from the command line (currently we use this mode for
component testing and debugging).
these components are AdaptiveTask hiers and they raise StopRunning when
a source of the jobs has been shut down and no further calls to
getWork() should be done.
this scheme works for the internet server: as you say, there always is
at least one reader (socket listener).
but when the component is started from the command line, there aren't
any readers or writers, and the processing is controlled by the task
queue only. when the component finishes it's work, StopRunning is
raised and we end up with the empty task queue and reactor doing nothing
(unless idleTimeout was set in the main loop).
> For other types of applications, the IMainLoop component manages idle
> timeouts, so that if no useful work occurs for some time period, the
> reactor will be shut down.
yes, but this would add an unnecessary idle time after completion of all
tasks, and each component should bother to set the timeout - additional
code and yet another place for programmer's mistakes.
> To be honest, I had never considered such a possibility, as every
> application scenario I envisioned for using the reactor either has an
> explicit shutdown command occurring, is explicitly time-bound (periodic
> task runner), or is a "run forever" loop.
are there any scenarios where reactor running without readers, writers
and queued tasks makes sense?
best wishes,
alex.
More information about the PEAK
mailing list