From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: don@donarmstrong.com (Emacs bug Tracking System) Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <86tzgq3ymq.fsf@macs.hw.ac.uk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----------=_1212117004-6208-0" X-Trace: ger.gmane.org 1212117123 2862 80.91.229.12 (30 May 2008 03:12:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 30 May 2008 03:12:03 +0000 (UTC) To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 30 05:12:44 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K1v2o-0001tt-32 for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 May 2008 05:12:42 +0200 Original-Received: from localhost ([127.0.0.1]:48170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K1v22-0001q3-GF for geb-bug-gnu-emacs@m.gmane.org; Thu, 29 May 2008 23:11:54 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K1v1x-0001oy-AK for bug-gnu-emacs@gnu.org; Thu, 29 May 2008 23:11:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K1v1w-0001oG-Gh for bug-gnu-emacs@gnu.org; Thu, 29 May 2008 23:11:48 -0400 Original-Received: from [199.232.76.173] (port=56604 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K1v1w-0001oC-Dl for bug-gnu-emacs@gnu.org; Thu, 29 May 2008 23:11:48 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:38858) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K1v1v-0004iB-9Q for bug-gnu-emacs@gnu.org; Thu, 29 May 2008 23:11:48 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m4U3BiuR007360; Thu, 29 May 2008 20:11:44 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m4U3A4S0006317; Thu, 29 May 2008 20:10:04 -0700 X-Mailer: MIME-tools 5.420 (Entity 5.420) X-Loop: don@donarmstrong.com X-Emacs-PR-Message: closed 300 X-Emacs-PR-Package: emacs X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:18184 Archived-At: This is a multi-part message in MIME format... ------------=_1212117004-6208-0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Your message dated Thu, 29 May 2008 23:05:14 -0400 with message-id and subject line Re: bug#300: strange interaction of periodic timers and su= spending 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 don@donarmstrong.com immediately.) --=20 300: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=3D300 Emacs Bug Tracking System Contact don@donarmstrong.com with problems ------------=_1212117004-6208-0 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-4.9 required=4.0 tests=BAYES_00,FOURLA, FVGT_m_MULTI_ODD,RCVD_IN_DNSWL_LOW autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 22 May 2008 19:52:38 +0000 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m4MJqSBV011459 for ; Thu, 22 May 2008 12:52:30 -0700 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JzGpw-00028b-CK for bug-gnu-emacs@gnu.org; Thu, 22 May 2008 15:52:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JzGpq-000229-Ok for bug-gnu-emacs@gnu.org; Thu, 22 May 2008 15:52:27 -0400 Received: from [199.232.76.173] (port=43592 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JzGpq-00021p-Bn for bug-gnu-emacs@gnu.org; Thu, 22 May 2008 15:52:22 -0400 Received: from mail-r.hw.ac.uk ([137.195.101.215]:59168) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JzGpp-0001jJ-Bw for bug-gnu-emacs@gnu.org; Thu, 22 May 2008 15:52:21 -0400 Received: from izanami.macs.hw.ac.uk ([137.195.13.6]) by mail-r.hw.ac.uk with esmtp (Exim 4.54) id 1JzGpc-0007BX-3Y for bug-gnu-emacs@gnu.org; Thu, 22 May 2008 20:52:08 +0100 Received: from lxultra1.macs.hw.ac.uk ([137.195.27.173]:46602 helo=127.0.0.1) by izanami.macs.hw.ac.uk with smtp (Exim 4.51) id 1JzGpb-0006c3-Su for bug-gnu-emacs@gnu.org; Thu, 22 May 2008 20:52:08 +0100 Received: (nullmailer pid 21720 invoked by uid 1001); Thu, 22 May 2008 19:52:13 -0000 From: Joe Wells To: bug-gnu-emacs@gnu.org Subject: strange interaction of periodic timers and suspending Emacs 22.1 Date: Thu, 22 May 2008 20:52:13 +0100 Message-ID: <86tzgq3ymq.fsf@macs.hw.ac.uk> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-HW-MailScanner-Information: Please contact the HW Helpdesk for more information X-HW-MailScanner: Found to be clean X-HW-MailScanner-SpamCheck: not spam, SpamAssassin (score=-4.399, required 5, autolearn=not spam, ALL_TRUSTED -1.80, BAYES_00 -2.60) X-HW-MailScanner-From: jbw@macs.hw.ac.uk X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) 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. ------------=_1212117004-6208-0 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-1.8 required=4.0 tests=AWL,BAYES_00,HAS_BUG_NUMBER, HELO_LH_HOME,RDNS_DYNAMIC autolearn=no version=3.2.3-bugs.debian.org_2005_01_02 Received: (at 300-done) by emacsbugs.donarmstrong.com; 30 May 2008 03:05:24 +0000 Received: from ceviche.home (206-248-174-248.dsl.teksavvy.com [206.248.174.248]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m4U35KuM005716 for <300-done@emacsbugs.donarmstrong.com>; Thu, 29 May 2008 20:05:22 -0700 Received: by ceviche.home (Postfix, from userid 20848) id 09BA0B41E2; Thu, 29 May 2008 23:05:15 -0400 (EDT) From: Stefan Monnier To: Joe Wells Cc: 300-done@emacsbugs.donarmstrong.com Subject: Re: bug#300: strange interaction of periodic timers and suspending Emacs 22.1 Message-ID: References: <86tzgq3ymq.fsf@macs.hw.ac.uk> <86y75txrbk.fsf@macs.hw.ac.uk> Date: Thu, 29 May 2008 23:05:14 -0400 In-Reply-To: <86y75txrbk.fsf@macs.hw.ac.uk> (Joe Wells's message of "Thu, 29 May 2008 12:50:07 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii > 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 ------------=_1212117004-6208-0--