bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#300: marked as done (strange interaction of periodic timers and sus


From: Emacs bug Tracking System
Subject: bug#300: marked as done (strange interaction of periodic timers and suspending Emacs 22.1)
Date: Thu, 29 May 2008 20:10:04 -0700

Your message dated Thu, 29 May 2008 23:05:14 -0400
with message-id <address@hidden>
and subject line Re: bug#300: strange interaction of periodic timers and 
suspending Emacs 22.1
has caused the Emacs bug report #300,
regarding strange interaction of periodic timers and suspending Emacs 22.1
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact address@hidden
immediately.)


-- 
300: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=300
Emacs Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: strange interaction of periodic timers and suspending Emacs 22.1 Date: Thu, 22 May 2008 20:52:13 +0100 User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)
Dear GNU Emacs gurus,

When Emacs 22.1 resumes from being suspended, it will execute a
periodic timer once for each time it would have executed it if Emacs
had never been suspended.  The same thing happens when the entire
computer is suspended (i.e., hibernation (suspend to disk) or sleep
(suspend to RAM)).

While it is conceivable that some uses of timers might prefer the
current behavior, in the vast majority of cases a timer does a
recurrent task and there is no benefit from repeating the timer
zillions of times in a row.  In fact, this can cause Emacs to freeze
for a long time when resuming due to processing periodic timers if the
timers do significant work.

It would be better if it was possible to get a periodic timer to
execute at most once for a period of time during which Emacs (or the
entire computer) was suspended.

Depending on your point of view, this is either a bug report (my
viewpoint) or a feature request.

To reproduce the behavior, start Emacs with this command:

  emacs -nw -Q

(You must be using a shell where the command "fg %1" will resume this
Emacs if it is suspended.  If not, adjust the reproduction code below
to use the correct command to resume Emacs.)

Then evaluate these 3 sexps:

  (defun foo-timer (x)
    (or (eq x 'xyzzy) (error "impossible"))
    (setq foo-counter (1+ foo-counter))
    ;;(message "foo-counter: %d" foo-counter)
    ;;(setq bar-counter foo-counter)
    (save-excursion
      (set-buffer foo-buffer)
      (goto-char (point-max))
      (insert (format " %d" foo-counter))))

  (defun foo-test ()
    (interactive)
    (and (boundp 'foo-timer)
         (timerp foo-timer)
         (cancel-timer foo-timer))
    (setq foo-counter 0)
    (setq foo-buffer-name "*foo-buffer*")
    (kill-buffer (get-buffer-create foo-buffer-name))
    (setq foo-buffer (get-buffer-create foo-buffer-name))
    ;; Once per second, starting now.
    (setq foo-timer (run-at-time t 1 #'foo-timer 'xyzzy))
    (switch-to-buffer foo-buffer)
    (sit-for 5)
    (goto-char (point-max))
    (insert " suspending")
    ;; extra BUG: In violation of its documentation, suspend-emacs
    ;; will add a newline or return character to the string it is
    ;; asked to stuff as terminal input.
    (suspend-emacs "sleep 10; fg %1")
    (goto-char (point-max))
    (insert " resuming")
    ;; possible extra BUG: It is strange that the (sit-for 0) needs to
    ;; be repeated to get all the events.  The first (sit-for 0)
    ;; generally only gets 3 events.
    (dotimes (x 20) (sit-for 0))
    (goto-char (point-max))
    (insert " canceling")
    (cancel-timer foo-timer)
    (buffer-string))

  (foo-test)

After this finishes, the contents of the *foo-buffer* buffer will be
(roughly) this string:

  " 1 2 3 4 5 suspending resuming 6 7 8 9 10 11 12 13 14 15 canceling"

The count can sometimes reach 6 before suspending and 16 before
canceling.

Instead of the current Emacs behavior, it would be very desirable to
be able to have periodic timers whose behavior would leave the
contents of the *foo-buffer* buffer as this string:

  " 1 2 3 4 5 suspending resuming 6 canceling"

It is very undesirable to have a periodic timer repeated zillions of
times upon resuming Emacs.  Note that the same problem happens when
the entire computer is suspended and resumed.

In addition to wanting to see this problem fixed, I would also be
interested to hear of a reliable way to work around it.

I hope this report is helpful.

-- 
Joe Wells

======================================================================
In GNU Emacs 22.1.1 (i686-pc-linux-gnu, GTK+ Version 2.8.20)
 of 2007-06-27 on artemis
configured using `configure  '--prefix=/home/jbw/local2' '--enable-debug' 
'--disable-nls' '--with-x-toolkit=gtk' 'CFLAGS=-O0 -g3 -ggdb''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: en_US.UTF-8
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: jbw
  value of $LANG: nil
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Fundamental

Minor modes in effect:
  encoded-kbd-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t


-- 
Heriot-Watt University is a Scottish charity
registered under charity number SC000278.





--- End Message ---
--- Begin Message --- Subject: Re: bug#300: strange interaction of periodic timers and suspending Emacs 22.1 Date: Thu, 29 May 2008 23:05:14 -0400 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)
> The case that bugs me enough to care is that I have a timer that
> invokes desktop-save roughly every 5 minutes.  (My scheme is a bit
> more clever than that and tries to save during idle times, but if it
> can't save during an idle time it will still ensure the desktop file
> is saved at least every 5 minutes.)  My desktop file is quite big

Of course, beside fixing your code to not use a repeating timer, but
a one-shot timer which you manually re-arm at the end, it turns out we
already have a variable to control this problem:

    timer-max-repeats


-- Stefan


--- End Message ---

reply via email to

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