Re: repeat something in a thread, but stop when the program stops

From: Tim Peters (tim.peters_at_gmail.com)
Date: 09/28/04


Date: Tue, 28 Sep 2004 12:41:03 -0400
To: python-list@python.org


[Tim Peters, on waking up a thread to check a queue 20 times a second]
>> Measure it: you won't be able to see a difference. Modern processors
>> cram on the order of 1E9 cycles into each second. Doing a tiny amount
>> of work 20 times per second is trivial.

[Harald Massa]
> You are surely right, Tim. Measuring did not detect the difference. I just
> see my tasktray collecting more and more icons of programs which just do a
> very tiny amount of work every half a second, and ... as them getting many,
> the computer begins to feel more sluggish.

Those are quite different, and they do more work than you may think.
For example, if a program puts an icon in the Windows systray, then it
has a graphical UI too, and has to run a Windows message pump to
detect stuff like "is the mouse hovering over my icon now? did they
click on me? did they right-click on me? did they double-click on
me?". Apps in the systray often do a lot more than just that too.
For example, one app in my systray right now hooks itself into the
Windows clipboard chain, and intercepts (and so also slows, by some
amount I couldn't care less about) all clipboard operations. Another
hooks itself into the file system at a low level, tracking all disk
changes, and so slows (by a measurable amount!) all disk writes.
Heck, the little systray icon showing the pressure on my laptop's
touchpad represents a process that has read over a billion bytes since
I last booted. Etc.

A Python thread waking up to see whether a Python Queue has something
in it does none of that stuff. If you have hundreds of Python threads
doing this, then you can start to think about maybe worrying when it
gets to thousands <wink>.



Relevant Pages

  • Re: Is it possible to remove 3rd party app icon from systray?
    ... that creates chaos in the systray. ... close the icon, ... My app starts the 3rd party app using runas, ... for command line options your 3rd party app might support. ...
    (microsoft.public.vb.general.discussion)
  • Re: Moving MsgBox
    ... started building a systray in my project using a DLL from the ... of/and OCX's is for placing an icon in the Systray, ... vertical bar graph's in their system tray icon to show UL & DL activity, ...
    (microsoft.public.vb.general.discussion)
  • Re: Some Systray icons disapear after explorer crash
    ... >> Some of my systray icons dissapear after the explorer ... >> explorer crashed, how would you get these icons to stay when explorer ... > when the app starts, it places it's icon in the system tray by telling ...
    (microsoft.public.windowsxp.general)
  • Re: Volume Control does not stay in Sys Tray
    ... SNDVOL32.exe from appearing in the SYSTRAY. ... > Troubleshooting the Volume Control Icon ... > Volume Icon Is Displayed Incorrectly in the Notification Area After the ...
    (microsoft.public.windowsxp.general)
  • IEXPLORE.EXE is not a valid Win32 application
    ... I have built a large amount of embedded images but never had this problem ... "IEXPLORE.EXE is not a valid Win32 application" ... This happens when clicking on the "Internet Explorer" icon, ...
    (microsoft.public.windowsxp.embedded)