emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sleep-for documentation and how to pause reliably


From: Thierry Volpiatto
Subject: Re: sleep-for documentation and how to pause reliably
Date: Fri, 15 Feb 2013 21:36:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.93 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> From: Thierry Volpiatto <address@hidden>
>> Date: Fri, 15 Feb 2013 11:19:27 +0100
>> 
>> > Am I missing something?  If not, apart of fixing the docs, _is_ there
>> > any way to wait reliably when async subprocesses are running and
>> > producing output?
>> What about using a sentinel?
>> 
>> (progn
>>   (let ((proc (start-process-shell-command "ls" nil "ls")))
>>     (set-process-sentinel proc #'(lambda (process event)
>>                                    (when (string= event "finished\n"))
>>                                    (sleep-for 20)
>>                                    (message "hi after 20s sleeping"))))
>>   (message "Hi now sleeping 20s"))
>
> Thanks, but that's not what I meant.  I meant, suppose you must
> reliably wait in a Lisp program that doesn't launch any subprocesses,
> but should always wait for N seconds even if there are some async
> subprocesses running in parallel.  IOW, the code that must pause
> doesn't itself launch any subprocesses, it just needs to wait.
Ok.

I tried to run the initial example you sent:

(progn
  (setq proc (start-process-shell-command "ls" nil "ls"))
  (sleep-for 20)
  (message "hi"))

and I noticed that the first time I eval the code Emacs wait for 20s as
expected and on next evaluations it send the message "Hi" immediately
unless I run `list-processes', wait some seconds and reeval it.

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]