Am 6. Oktober 2010 11:58 schrieb Iustin Pop <[email protected]>:
> --- a/lib/daemon.py
> +++ b/lib/daemon.py
> -def GenericMain(daemon_name, optionparser, check_fn, exec_fn,
> +def GenericMain(daemon_name, optionparser,
> +                check_fn, prepare_fn, exec_fn,

… if only it was a class, adding a new method would be so much simpler
and data could be stored in instance variables.

> […]
> -    exec_fn(options, args)
> +    if callable(prepare_fn):
> +      prep_results = prepare_fn(options, args)
> +    else:
> +      prep_results = None
> +
> +    exec_fn(options, args, prep_results)

I don't like this very much. Passing a callback to both check_fn and
exec_fn that can be called when the daemon is ready (e.g. after
listen(2)) would be better in my opinion, but you mentioned that you
don't like it.

If you insist on this solution, LGTM.

>   finally:
>     utils.RemovePidFile(daemon_name)

Regards,
Michael

Reply via email to