Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38489
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: Monitoring updating directory for image for GUI |
| Date | 2013-02-08 20:32 -0500 |
| Organization | > Bestiaria Support Staff < |
| References | <8a572770-9cc1-4b65-9053-10fd6c2f543b@googlegroups.com> <mailman.1440.1360218333.2939.python-list@python.org> <02bee1ed-1a9b-4cac-975a-098b3382250f@googlegroups.com> <mailman.1466.1360288892.2939.python-list@python.org> <8f8eaf8f-2572-4843-87f0-3bafaf98472b@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1528.1360373560.2939.python-list@python.org> (permalink) |
On Fri, 8 Feb 2013 09:09:31 -0800 (PST), ciscorucinski@gmail.com
declaimed the following in gmane.comp.python.general:
>
> That is what I am trying to figure out how to do. I have a counter that updates with every note that is grabbed from the stream. That counter is passed into a threaded class that might or might not create the image right away...but seems to create them sequentially from what I have seen so far (I don't know if that is absolute thought).
>
> Please let me know you thought on the above part! Each new thread should only take only a very small amount longer to do than the previous thread that was started...because it has one more note to deal with this time.
>
> Anyways...I do have the count of the latest image that WILL BE created...but by the time that one is created in the directory, a new note is most likely streamed in and replaces that count. Therefore, I cannot really do that...I think.
>
> hmmmm, I wonder. I create the images via OS command that will .wait() on a subprocess.Popen(). I could increment the counter there? Or do something there that will let me know of the most recent image file via a counter or something? But it needs to be thread-safe
>
One problem I see is a race condition. Unless you have some sort of
completion flag from the program generating the images you can't rely on
the "newest" file in the directory being a complete image.
So... You either run one image behind if just looking at directory
contents (on the basis the newest image file is still being written); or
you have to run lock-step with the image generator, where it signals
when <file-n> is available.
If monitoring a directory for changes, and you are on Windows, I
believe there is a native Win32 API to catch changes to directories.
{I'm still waiting for Windows Internals Part 2 to arrive -- though this
series is closer to the old VMS "black book" than to a reference manual
for Windows system calls}
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365261%28v=vs.85%29.aspx
You still have the chase condition unless you code a two level
change...
displayFile = None
inWorkFile = None
while True:
#wait for change notification of new file (ignore times, etc.)
displayFile = inWorkFile
inWorkFile = #whatever the change notification reported
if displayFile:
#do something with completed file
... and that leaves the matter of handling the last file when you
conclude there will be no more updates.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Monitoring updating directory for image for GUI ciscorucinski@gmail.com - 2013-02-06 14:02 -0800
Re: Monitoring updating directory for image for GUI Chris Angelico <rosuav@gmail.com> - 2013-02-07 17:25 +1100
Re: Monitoring updating directory for image for GUI ciscorucinski@gmail.com - 2013-02-07 16:48 -0800
Re: Monitoring updating directory for image for GUI Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-08 02:01 +0000
Re: Monitoring updating directory for image for GUI ciscorucinski@gmail.com - 2013-02-08 09:09 -0800
Re: Monitoring updating directory for image for GUI Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-09 00:53 +0000
Re: Monitoring updating directory for image for GUI Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-08 20:32 -0500
Re: Monitoring updating directory for image for GUI ciscorucinski@gmail.com - 2013-02-08 09:09 -0800
Re: Monitoring updating directory for image for GUI ciscorucinski@gmail.com - 2013-02-07 16:48 -0800
Re: Monitoring updating directory for image for GUI Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2013-02-07 11:25 +0100
Re: Monitoring updating directory for image for GUI Piet van Oostrum <piet@vanoostrum.org> - 2013-02-07 18:11 +0100
Re: Monitoring updating directory for image for GUI ciscorucinski@gmail.com - 2013-02-11 14:50 -0800
Re: Monitoring updating directory for image for GUI MRAB <python@mrabarnett.plus.com> - 2013-02-11 23:50 +0000
Re: Monitoring updating directory for image for GUI Piet van Oostrum <piet@vanoostrum.org> - 2013-02-13 17:09 +0100
csiph-web