Re: email from timer

Martin Simmons <[email protected]> Wed, 28 Mar 2007 14:57:18 +0100
Newsgroups gmane.lisp.cl-http
Message-ID <[email protected]>
>>>>> On Tue, 27 Mar 2007 13:42:05 -0400, Mark Klein said:
> 
> I'd like to have a periodic process that sends email if certain 
> conditions are met, but when I try the following
> 
> (defun start-watching (&optional (period 600))
>    (labels ((check  ()
>                    (when <conditions-are-met>
>                          (WWW-UTILS:SEND-MAIL-FROM  ...))))
>      (setq *watch-process* (mp:make-named-timer "Watcher" #'check))
>      (mp:schedule-timer-relative *watch-process* 0 period)))
> 
> I get the error "PROCESS-WAIT when scheduling not allowed" whenever 
> send-mail-from is invoked from within "check". Perhaps send-mail-from 
> does some scheduling itself, but that is not allowed from within the 
> context of a scheduled function?

Correct

 
> What can I do to fix this?

The call to WWW-UTILS:SEND-MAIL-FROM has to be done later, e.g. you could
launch a new process to do it.

You might have similar issues in the <conditions-are-met> part.  Beware that
the timer runs asynchronously relative to other threads, so for example it can
happen while data structures are being updated.  If that is a problem, then I
suggest having a watchdog process than just does

(loop (sleep period)
      (when <conditions-are-met>
        (WWW-UTILS:SEND-MAIL-FROM  ...)))

__Martin

_______________________________________________
WWW-CL mailing list
[email protected]
https://lists.csail.mit.edu/mailman/listinfo/www-cl