On 8 February 2013 17:09, <[email protected]> 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
--
http://mail.python.org/mailman/listinfo/python-list