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

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

Re: Idel time continually around 60 seconds


From: Cecil Westerhof
Subject: Re: Idel time continually around 60 seconds
Date: Thu, 11 Jan 2018 18:24:32 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Cecil Westerhof <address@hidden> writes:

> Narendra Joshi <address@hidden> writes:
>
>> Cecil Westerhof <address@hidden> writes:
>>
>>> I am using Gnus and I have installed a daemon that depending on the
>>> amount of idle time does something, or not. But strangely the idle
>>> time is continuously around 60 seconds. (And I want it to be more.)
>>>
>>> I added some debugging to my daemon routine:
>>> 2018-01-10 14:33:49: Starting gnus-idle-daemon ((23126 5693 809219 184000), 
>>> (0 60 3465 810000))
>>>            14:33:50: Leaving gnus-idle-daemon (1 second, (0 60 604458 
>>> 776000))
>>> 2018-01-10 14:34:50: Starting gnus-idle-daemon ((23126 5754 456491 143000), 
>>> (0 60 858 915000))
>>>            14:34:50: Leaving gnus-idle-daemon (0 seconds, (0 60 516542 
>>> 418000))
>>> 2018-01-10 14:35:51: Starting gnus-idle-daemon ((23126 5815 17667 46000), 
>>> (0 60 792 785000))
>>>            14:35:51: Leaving gnus-idle-daemon (0 seconds, (0 60 499851 
>>> 979000))
>>> 2018-01-10 14:36:51: Starting gnus-idle-daemon ((23126 5875 570675 402000), 
>>> (0 60 712 877000))
>>>            14:36:52: Leaving gnus-idle-daemon (1 second, (0 60 490399 
>>> 246000))
>>> 2018-01-10 14:37:52: Starting gnus-idle-daemon ((23126 5936 115162 38000), 
>>> (0 60 696 902000))
>>>            14:37:52: Leaving gnus-idle-daemon (0 seconds, (0 60 541211 
>>> 971000))
>>>
>>> When entering I display the values of current-time and
>>> current-idle-time. When leaving only current-idle-time.
>>>
>>> What could be the reason of this?
>> Can you share the code you are using for the above?
>
> It is a lot of code, but I shall give the gist.

It needed some digging, but I found the problem: it is write-region.
But the strange part is that it only happens after the calling
function is finished.

I create a separate message for this.


> Activating is done with:
>     (gnus-demon-add-handler 'dcbl-gnus-idle-daemon 1 nil)
>
> I changed the last parameter to nil, so the daemon routine is called
> every minute. If the system has been idle, or not.
>
> The routine itself (which calls other functions again) is:
>     (defun dcbl-gnus-idle-daemon ()
>       "Do potential time consuming things when Emacs is idle;
>     At the moment:
>     - dcbl-gnus-delay-send-queue
>     - gnus-group-get-new-news.
>     - gnus-group-expire-all-groups"
>       (setq dcbl-gnus-current-log-format 'start)
>       (let ((log-enter-and-leave (and (integerp dcbl-gnus-idle-daemon-do-log)
>                                       (>=       dcbl-gnus-idle-daemon-do-log 
> 10)))
>             (start-time          (current-time)))
>         (when log-enter-and-leave
>           (dcbl-gnus-log-message (format "Starting gnus-idle-daemon (%s, %s)"
>                                          (current-time) (current-idle-time))))
>         (when (and dcbl-gnus-idle-daemon-semafoor
>                    (>= (time-difference dcbl-gnus-idle-daemon-semafoor 
> (current-time))
>                        (* 15 +seconds-in-minute+)))
>           (setq dcbl-gnus-current-log-format 'start)
>           (dcbl-gnus-log-message "ERROR: Needed to reset 
> gnus-idle-daemon-semafoor")
>           (setq dcbl-gnus-idle-daemon-semafoor nil))
>         (unless dcbl-gnus-idle-daemon-semafoor
>           (setq dcbl-gnus-idle-daemon-semafoor (current-time))
>           (condition-case err
>               ;; Protected form.
>               (dolist (poll-element dcbl-gnus-poll-struct)
>                 (dcbl-gnus-idle-daemon-call-function poll-element))
>             ;; The handler.
>             (error
>              (dcbl-gnus-log-message (format
>                                      "Error in dcbl-gnus-idle-daemon dolist: 
> %s"
>                                      err))
>              nil))
>           (setq dcbl-gnus-idle-daemon-semafoor nil))
>         (when log-enter-and-leave
>           (dcbl-gnus-log-message (format "Leaving gnus-idle-daemon (%s, %s)"
>                                          (time-difference-formatted 
> start-time)
>                                          (current-idle-time))))))
>
> When not using Emacs, but playing a video through mpv, I get:
> 2018-01-10 22:32:35: Starting gnus-idle-daemon ((23126 34419 369076 610000), 
> (0 0 658640 85000))
>            22:32:36: Leaving gnus-idle-daemon (1 second, (0 1 392452 151000))
> 2018-01-10 22:33:35: Starting gnus-idle-daemon ((23126 34479 369090 736000), 
> (0 0 753334 161000))
>            22:33:36: Leaving gnus-idle-daemon (1 second, (0 1 562405 319000))
> 2018-01-10 22:34:35: Starting gnus-idle-daemon ((23126 34539 368969 98000), 
> (0 0 673375 295000))
>            22:34:36: Leaving gnus-idle-daemon (1 second, (0 1 432972 290000))
>
> So mpv looks to make Emacs think it is not idle at all.
>
> After this I let Emacs be idle for a few minutes and this gave the
> following:
> 2018-01-10 22:42:35: Starting gnus-idle-daemon ((23126 35019 371985 309000), 
> (0 59 125327 787000))
>            22:42:36: Leaving gnus-idle-daemon (1 second, (0 60 16979 177000))
> 2018-01-10 22:43:35: Starting gnus-idle-daemon ((23126 35079 371650 415000), 
> (0 59 52674 710000))
>            22:43:36: Leaving gnus-idle-daemon (1 second, (0 59 827891 167000))
> 2018-01-10 22:44:35: Starting gnus-idle-daemon ((23126 35139 370952 276000), 
> (0 59 165616 289000))
>            22:44:36: Leaving gnus-idle-daemon (1 second, (0 59 913835 893000))
> 2018-01-10 22:45:35: Starting gnus-idle-daemon ((23126 35199 371468 342000), 
> (0 59 196502 494000))
>            22:45:36: Leaving gnus-idle-daemon (1 second, (0 60 8895 962000))
>
> So my routine does nothing to change idle time, but when coming back,
> it is as if idle time was reset.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


reply via email to

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