Re: how to "kill" a job
[email protected] ((Justin Mason)) Wed, 02 Feb 2005 18:59:06 -0800
| Newsgroups | perl.ipc.dirqueue |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Bruce Robertson writes: > Is there such an API point? > If not, do you have something under development? > Else, any pointers on how to do it? There isn't yet such a thing, no, and I haven't planned it. (yet) Kill an as-yet unprocessed job would be easy -- simply an unlink. But if the job is active, it'd be quite a bit harder; it's easy in the LPR-style of queueing, because that has (a) a central server and (b) each job is a separate process, so a kill(3) of the process can be used to kill the job, but in DQ, there's no separate process per job -- one process can deal with many jobs sequentially. I would say the cleanest way to do it would be to arrange that dq servers can provide a new constructor switch indicating a signal that should be delivered if a job kill is to be requested; if that switch isn't present, killing an active job isn't supported. The DQ server code would then write that to a flag file in the queue directory, so that DQ clients (ie. a new "dq-kill" script) can be aware that the server(s) support this. The server code should then implement a signal handler for that signal; that handler will check to see if it is currently processing a killed job (ie. if the data file has been unlinked before it's complete), and give up the remainder of the job's processing if it is. (alternatively, the server could just ignore the signal, if it's not an issue for that server's design, e.g. if the jobs are very lightweight, and completing processing of a killed job will not cause problems.) If that constructor switch was not specified, I think it would be unsafe to assume that DQ kill is supported by that queue; we can't go unlinking active jobs without some kind of "this is supported" negotiation, as a disappearing job file may cause a die() in server code that wasn't aware this was likely to happen. - --j. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Exmh CVS iD8DBQFCAZN6MJF5cimLx9ARAr5NAJ0XaiEfTu55tve/g2gmuylLfwrK7wCdF2yF dLOlbsvNhHl50TfJYtzwJfA= =jxvb -----END PGP SIGNATURE-----