On Fri, 3 Mar 2023, at 22:55, Clayton Macleod wrote:

> It doesn't really matter whether or not the playlist exists already.  That
> doesn't have anything to do with the issue..... 
>
> Everything works great until I make that delete call.

That's not what you said at the start.  Then, you said it (also) errors 
sometimes when you try to add a track.

I wondered if those erroring adds/deletes were happening at the 
boundary where songs end/start playing.


> As I already said, when I noticed there was a problem I pared the script
> down to the bare minimum to try to figure out what was going on. So the
> only things it was doing was downloading the song library list and then
> printing out the song.Name entries at random with the main loop modified
> just to print in order to troubleshoot things.

> That successfully completed 100% of the time.  

Which is probably because the relationship between song entries and their
names wasn't being changed by anything,

But (maybe?) the places where you had failures to print names were when 
you tried to follow a pointer from a track to a song to a name; if the 
relationship between track & song is corrupted that won't work.

Remembering that I don't use iTunes ... I wondered if the iTunes application
(when you use it via its GUI) supports dynamic changes to a playlist when
that playlist is being played?

I also wondered just how often your add/deletes failed?  Are you adding a 
track at the instant that your app notices that iTunes has just reached the 
end of one track and started the next, and presumably at that point 
removed the just-played track from the playlist?

That is, maybe there's a timing problem.  If your code just happens to try to
alter the playlist at the same time as iTunes is doing so itself, maybe that 
doesn't work - so maybe (if you're doing your change when you think it's
needed) you could wait 5 seconds and then try it.

It also struck me that in the GUI application - even if as a user you may think 
you can make changes to playlists at any time - the GUI may inhibit user-made
changes for a few fractions of a second if IT is about to make a change, but 
the COM interface might just be offering you the code that makes the 
change without the locking around it.

So eg you might need to search the iTunes COM docs (I know there's some, 
I found them, but maybe not uptodate, and maybe not complete?) for any
sign of "locks" or "serialisation" or "queuing" or "data integrity" controls to
prevent the app and you simultaneously updating a data structure inside 
iTunes.  [I don't know the right terminology for this, other than on the IBM
mainframes I used to work with, sorry.]  It's also possible that - say - it 
renumbers or completely rebuilds a playlist structure whenever it changes.
I wondered if, if that's so, your code would get the rebuilt one each time.

-- 
Jeremy Nicoll - my opinions are my own.
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to