Probably some object is still holding a reference to the source. Normally Python calls __delete__ and frees the instance the moment its ref count goes to 0 (last reference is cleared). The 'garbage collector' is only used to clean up cyclic references. I suspect the internal audio player is still holding a reference to a source group containing the source, although that should be cleaned up when the player is deleted.
Rob Op dinsdag 31 maart 2015 17:25:07 UTC+2 schreef Russell Valentine: > > If it is a avbin media, as a workaround, I've found I can manually do: > > self._source.__del__() > > I am then able to delete it. That should work for me. But it wouldn't work > if it is a non avbin media. I wonder why __del__ doesn't get called when I > do gc.collect() > > > On Monday, 30 March 2015 19:36:27 UTC-5, Russell Valentine wrote: >> >> Been liking pyglet so far. Nice job! I did run into a problem I have not >> figure out. >> >> I fetch a file on the internet and store it as a temporary file. When I'm >> doing playing it I want to delete it. I do something like the following, >> where self._player is a pyglet.media.Player. self._source is a streaming >> store created from the temporary file. self._tmp_fn is the temporary >> filename. >> >> def close(self, args=None): >> if self._player: >> self._player.delete() >> self._player = None >> self._source = None >> gc.collect() >> if self._tmp_fn: >> os.unlink(self._tmp_fn) >> self._tmp_fn = None >> >> >> Seems okay but on windows when I try to delete self._tmp_fn I get: >> >> WindowsError: [Error 32] The process cannot access the file because it is >> being used by another process: 'c:\\path_to_tempfile\\tempfile' >> >> How do I make sure pyglet isn't using the file any more so I can delete >> it? >> >> Thank you. >> >> -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pyglet-users. For more options, visit https://groups.google.com/d/optout.
