Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38485

Re: Monitoring updating directory for image for GUI

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>
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date 2013-02-09 00:53 +0000
Subject Re: Monitoring updating directory for image for GUI
Newsgroups comp.lang.python
Message-ID <mailman.1524.1360371249.2939.python-list@python.org> (permalink)

Show all headers | View raw


 On 8 February 2013 17:09,  <ciscorucinski@gmail.com> wrote:
>> So you have a thread that updates the image and then checks the stack
>> to see if a new image is available? Can you not just have it only try
>> to load the newest image?
>
> 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.

Are you creating a new thread for each new note? I imagined that you
would have 3 threads: producer, organiser and consumer. It looks like
this:

# Producer:
for x in produce_music():
    counter += 1
    create_note_file(filename)
    notes_map[filename] = counter

# Organiser
def on_file_notify(filename):
    if notes_map[filename] > notes_map[waiting]:
        waiting = filename

# Consumer
while True:
    if waiting is not None:
        display(waiting)
        waiting = None
    else:
       sleep()

[SNIP]
>
> I am not notified when the file is created...but like I said before, I wait on the subprocess and could do something there.

I don't understand your setup.

>
>> Is that using something like watchdog?
>> http://pypi.python.org/pypi/watchdog
>
> I don't know about Watchdog...but from an earlier version of a tutorial online...
>
> http://pypi.python.org/pypi/watchdog/0.3.6  (Yes, it is currently on v0.6.0 and this is older - v0.3.6)
>
> ... it looks like I COULD do something like...

I haven't actually used watchdog myself. I was just querying how you
were getting updates about file changes (and suggesting to use a PyPI
package since at least one was available for your needs).


Oscar

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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