Sorry, forgot to hit reply all. Been many years since I've used mailing lists, and I'm surprised anyone still does. Heh. Anyway...
Perhaps this isn't very clear. I've found a case where the pywin32 COM library is causing data corruption and I'm trying to make a bug report. I'm not having trouble figuring out how to write code in and use python. I found a bug. And wish to report that bug to the people that would be responsible for squashing bugs in the software they write/maintain. What it is, what is happening, as opposed to what should be happening. I opened an issue on git, where you normally report bugs in software that is hosted on git, but apparently they don't want bug reports in the bug reports section. Whatever sense that makes. The issue was closed without even considering anything in it, despite the fact that it is an actual bug. The idea behind my script is very simple, as is the script to carry out the idea. I have very simple code that should work as designed, but something in the pywin32 COM library is failing under a certain circumstance and causing data corruption in that case. Something which I have now figured out how to make happen on demand. Which is usually what you do when reporting bugs. Figure out if there are steps to reliably reproduce the problem. And if there are, list those steps so developers writing/maintaining that software can reproduce the error and try to figure out why it is happening. It doesn't really matter whether or not the playlist exists already. That doesn't have anything to do with the issue. The script alters the playlist in iTunes in real-time as iTunes is playing music so that it plays a continuous stream of music with the ratio of rated songs that I desire. If iTunes isn't running when the script starts the COM connection attempt fires up iTunes on its own. If it is already playing that playlist it doesn't interrupt playback. If it is playing music but isn't already playing that playlist it starts playing that playlist from the first track. iTunes has the music. iTunes is playing the music. I'm just making/updating the playlist in iTunes. I download the song library list from iTunes, and make randomized choices based on song ratings which is what the playlist is populated from. Everything works great until I make that delete call. After the delete call the script's data seems to be corrupted. If I never make the delete call the script's data remains intact. The significance of doing something 1,000 times is debugging with enough repetition to try to get a good idea of what is going on. I was trying to troubleshoot what was going on by following basic troubleshooting steps. Since I have thousands of songs in the library, and since it was failing with what seemed to be random entries in that list, I figured printing out the randomized song.Name entries 1,000 times would give me a good sample size to try to get some idea of how much of the data was being corrupted. I'm not going to print out one sample and get one error and say 100% of my data is corrupted. I'm going to print out 1000 and if I see 700 errors then there's a good chance 70% of the data was corrupted. 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. debug_loop = 0 while debug_loop < 1000: #while len(playlist.Tracks) < 25: debug_loop += 1 #time.sleep(1) # Select a random rating group rating = random.choice(rating_weighting) # Select a random song from that rating group song = random.choice(grouped_songs[rating]) # Add the song to the playlist if it's not already there print("Topping up...", rating) if song not in playlist.Tracks: # print("song.Name:", song.Name) # playlist.AddTrack(song) try: print("song.Name:", song.Name) #playlist.AddTrack(song) except pywintypes.com_error as e: # I no longer care to see the errors because I can't do anything about them anyway. pass That successfully completed 100% of the time. It didn't matter how many times I tried it. It always printed all 1,000 attempts successfully. So when it was obvious that that was working correctly I just continued following basic troubleshooting steps. I added commands back in one at a time and tried running it again to see what the debug loop did after adding one more command back in. If it continues working then whatever command you just added back in probably wasn't involved in the problem. And then you continue adding and retrying. As I already said, this worked perfectly fine until I got to the point where I added the delete command back in. Immediately after adding the delete command back in the script's data would get corrupted and the failure rate of printing song.Name was very bad. It went from dozens of attempts before adding delete back all coming back with zero errors, to adding the delete command back in and getting 564/1000 errors, 575/1000 errors, 338/1000 errors, 131/1000 errors, 976/1000 errors, 906/1000 errors, 794/1000 errors during the test runs with the delete command present. I'm assuming that COM calls consist of the call itself and a response to the call. Perhaps something in the response to the "playlist.Tracks[0].Delete()" calls and how that's handled by the COM library when it receives the reply is what is responsible for corrupting the python script's own data. That's what seems to be going on to me. If the exact same code runs just fine if that command is avoided and then immediately fails horribly if that command is used I don't know what other conclusion to come to. On Fri, Mar 3, 2023 at 9:18 AM Jeremy Nicoll <jn.ml.pyth...@letterboxes.org> wrote: > Why did you not reply to the list where other people could see your reply? > > > On Fri, 3 Mar 2023, at 16:46, Clayton Macleod wrote: > > Well, the first thing I do is grab a list of the entire song library. > Then > > I create a playlist. > > The code says it uses an existing playlist unless it doesn't exist. Unless > you're manually deleting it after each run, surely it will exist already. > > > The entries in this playlist are the only things that > > get deleted, so the song list that I grabbed is still valid. > > What happens if you run the iTunes application while your script is > running? If that's possible can you see your playlist's contents being > changed? > > > But I'm not > > keeping track of the playlist or its deletions in the script because I > > don't think I need to since iTunes is holding a copy of it. > > Isn't the playlist that you're manipulating /the one that iTunes has/ ... > ie not a copy of it? > > If your playlist is not iTunes playlist (of the specified name) how on > earth does your one affect what iTunes is doing? > > > > I'm only > > referring again to items in the initial list that have not changed. But > the > > deletion call seems to cause my copy of that initial list to get > corrupted > > somehow as trying to print song.Name fails on hundreds of attempts out > of a > > loop of 1,000 attempts. > > This 1.000 attempts code ... it's not in the source code you posted, or is > it? > My python knowledge is rusty. And if your playlist only contains a max of > 25 items, what is the significance of doing something 1000 times? > > -- > Jeremy Nicoll - my opinions are my own. > _______________________________________________ > python-win32 mailing list > python-win32@python.org > https://mail.python.org/mailman/listinfo/python-win32 > -- Clayton Macleod If no one comes from the future to stop you from doing it, then how bad of a decision can it really be?
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32