* Timers and sentinels
@ 2010-09-25 13:49 Lars Magne Ingebrigtsen
2010-09-26 11:09 ` Uday S Reddy
0 siblings, 1 reply; 8+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-09-25 13:49 UTC (permalink / raw)
To: emacs-devel
I'm trying to track down a bug that's pretty elusive. I may be looking
in the totally wrong place, but what seems to happen is that I have a
function (run from a timer) that alters some part of the Gnus article
buffer. At the same time, there's an URL process filter/sentinel that's
being run, and inserts images asynchronously into the buffer.
Is it possible that the function that's being run from the timer is
being interrupted by the process filter/sentinel function? I had half
imagined that all these "multi-threaded" functions were being run with,
er, "interrupts off", so to speak.
--
(domestic pets only, the antidote for overdose, milk.)
larsi@gnus.org * Lars Magne Ingebrigtsen
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Timers and sentinels
2010-09-25 13:49 Timers and sentinels Lars Magne Ingebrigtsen
@ 2010-09-26 11:09 ` Uday S Reddy
2010-09-26 11:56 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 8+ messages in thread
From: Uday S Reddy @ 2010-09-26 11:09 UTC (permalink / raw)
To: emacs-devel
On 9/25/2010 2:49 PM, Lars Magne Ingebrigtsen wrote:
> I'm trying to track down a bug that's pretty elusive. I may be looking
> in the totally wrong place, but what seems to happen is that I have a
> function (run from a timer) that alters some part of the Gnus article
> buffer. At the same time, there's an URL process filter/sentinel that's
> being run, and inserts images asynchronously into the buffer.
>
> Is it possible that the function that's being run from the timer is
> being interrupted by the process filter/sentinel function? I had half
> imagined that all these "multi-threaded" functions were being run with,
> er, "interrupts off", so to speak.
Whenever the "main" Emacs thread does an accept-process-output or sit-for,
timer tasks can run. I was also bitten by this issue a few times. It is
important that the timer tasks be short and refrain from changing any important
state that might affect the main thread.
The JUST-THIS-ONE argument of accept-process-output can be used to "turn off
the interrupts", so to speak.
Cheers,
Uday
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Timers and sentinels
2010-09-26 11:09 ` Uday S Reddy
@ 2010-09-26 11:56 ` Lars Magne Ingebrigtsen
2010-09-26 13:20 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-09-26 11:56 UTC (permalink / raw)
To: emacs-devel
Uday S Reddy <u.s.reddy@cs.bham.ac.uk> writes:
> Whenever the "main" Emacs thread does an accept-process-output or
> sit-for, timer tasks can run. I was also bitten by this issue a few
> times. It is important that the timer tasks be short and refrain from
> changing any important state that might affect the main thread.
Hm. Yes, nothing will be preempted unless they call sit-for or
accept-process-output or the like in the main thread, so it sounds
unlikely that a timer task will be preempted unless the same occurs.
Which it doesn't, so there must be a different kind of bug in the
code...
--
(domestic pets only, the antidote for overdose, milk.)
larsi@gnus.org * Lars Magne Ingebrigtsen
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Timers and sentinels
2010-09-26 11:56 ` Lars Magne Ingebrigtsen
@ 2010-09-26 13:20 ` Eli Zaretskii
2010-09-26 13:24 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2010-09-26 13:20 UTC (permalink / raw)
To: Lars Magne Ingebrigtsen; +Cc: emacs-devel
> From: Lars Magne Ingebrigtsen <larsi@gnus.org>
> Date: Sun, 26 Sep 2010 13:56:20 +0200
> Mail-Copies-To: never
>
> Uday S Reddy <u.s.reddy@cs.bham.ac.uk> writes:
>
> > Whenever the "main" Emacs thread does an accept-process-output or
> > sit-for, timer tasks can run. I was also bitten by this issue a few
> > times. It is important that the timer tasks be short and refrain from
> > changing any important state that might affect the main thread.
>
> Hm. Yes, nothing will be preempted unless they call sit-for or
> accept-process-output or the like in the main thread, so it sounds
> unlikely that a timer task will be preempted unless the same occurs.
> Which it doesn't, so there must be a different kind of bug in the
> code...
Before you conclude that your initial guess was wrong, there's one
more factor to consider: signals. When a subprocess exits, Emacs gets
a SIGCHLD signal, which is an asynchronous event. There are also the
SIGALRM signals caused by the hourglass-cursor feature. Not sure if
this can explain the issue you are dealing with, but I though I'd
mention it just in case.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Timers and sentinels
2010-09-26 13:20 ` Eli Zaretskii
@ 2010-09-26 13:24 ` Lars Magne Ingebrigtsen
2010-09-26 15:19 ` Helmut Eller
2010-09-26 18:36 ` Eli Zaretskii
0 siblings, 2 replies; 8+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-09-26 13:24 UTC (permalink / raw)
To: emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
> Before you conclude that your initial guess was wrong, there's one
> more factor to consider: signals. When a subprocess exits, Emacs gets
> a SIGCHLD signal, which is an asynchronous event. There are also the
> SIGALRM signals caused by the hourglass-cursor feature. Not sure if
> this can explain the issue you are dealing with, but I though I'd
> mention it just in case.
Hm. What I'm seeing is that (possibly) the function being run from the
timer is interrupted by an image insertion, and the latter is being run
off of url-fetch, which, I guess, is a sentinel function. Which might
be triggered when the subprocess exits... Hm... but is that possible?
--
(domestic pets only, the antidote for overdose, milk.)
larsi@gnus.org * Lars Magne Ingebrigtsen
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Timers and sentinels
2010-09-26 13:24 ` Lars Magne Ingebrigtsen
@ 2010-09-26 15:19 ` Helmut Eller
2010-09-26 18:36 ` Eli Zaretskii
1 sibling, 0 replies; 8+ messages in thread
From: Helmut Eller @ 2010-09-26 15:19 UTC (permalink / raw)
To: emacs-devel
* Lars Magne Ingebrigtsen [2010-09-26 13:24] writes:
> Hm. What I'm seeing is that (possibly) the function being run from the
> timer is interrupted by an image insertion, and the latter is being run
> off of url-fetch, which, I guess, is a sentinel function. Which might
> be triggered when the subprocess exits... Hm... but is that possible?
No. The only "interrupt" at Lisp level is C-g. Everything else is
called by the event loop. C level signal handlers have to put stuff in
a queue and the event loop will look there when it gets to it. C level
signal handlers can't call Lisp code (just imagine what would happen if
the GC were interrupted by a signal and the signal handler would call
Lisp code).
With timers you have to watch out for the (IMO counterproductive)
condition-case in timer-event-handler which swallows all errors without
giving you a notice.
Helmut
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Timers and sentinels
2010-09-26 13:24 ` Lars Magne Ingebrigtsen
2010-09-26 15:19 ` Helmut Eller
@ 2010-09-26 18:36 ` Eli Zaretskii
2010-09-26 18:53 ` Lars Magne Ingebrigtsen
1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2010-09-26 18:36 UTC (permalink / raw)
To: Lars Magne Ingebrigtsen; +Cc: emacs-devel
> From: Lars Magne Ingebrigtsen <larsi@gnus.org>
> Date: Sun, 26 Sep 2010 15:24:01 +0200
>
> What I'm seeing is that (possibly) the function being run from the
> timer is interrupted by an image insertion
Can you tell more about this "interruption"? In particular, how did
you conclude the timer function was interrupted?
> and the latter is being run off of url-fetch, which, I guess, is a
> sentinel function.
What is url-fetch? I don't see such a function in the Emacs sources.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Timers and sentinels
2010-09-26 18:36 ` Eli Zaretskii
@ 2010-09-26 18:53 ` Lars Magne Ingebrigtsen
0 siblings, 0 replies; 8+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-09-26 18:53 UTC (permalink / raw)
To: emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
> Can you tell more about this "interruption"? In particular, how did
> you conclude the timer function was interrupted?
I haven't concluded that. :-) I was just wondering whether that was at
all possible, and if not, the bug must lie elsewhere...
> What is url-fetch? I don't see such a function in the Emacs sources.
Sorry. `url-retrieve'.
--
(domestic pets only, the antidote for overdose, milk.)
larsi@gnus.org * Lars Magne Ingebrigtsen
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-09-26 18:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-25 13:49 Timers and sentinels Lars Magne Ingebrigtsen
2010-09-26 11:09 ` Uday S Reddy
2010-09-26 11:56 ` Lars Magne Ingebrigtsen
2010-09-26 13:20 ` Eli Zaretskii
2010-09-26 13:24 ` Lars Magne Ingebrigtsen
2010-09-26 15:19 ` Helmut Eller
2010-09-26 18:36 ` Eli Zaretskii
2010-09-26 18:53 ` Lars Magne Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.