|
From: Dominic S. <dom...@gm...> - 2009-12-12 05:19:42
|
On Thursday 10 of December 2009 18:58:24 Stephen Sinclair wrote: > > The only solution I can think of is an explicit free() method for > > the server classes, so you don't need to rely on Python's reference > > counting/garbage collection to do the right thing. Could you try > > the attached patch? > > What about changing: > > def __dealloc__(self): > lo_server_thread_free(self._thread) > > to: > > def __dealloc__(self): > lo_server_thread_stop(self._thread) > lo_server_thread_free(self._thread) > > ? > > I think the extra _stop() will not cause any harm if it's already > been called, since liblo tracks the active status of server threads. The first thing lo_server_thread_free() does is to call lo_server_thread_stop() if the server is still active, so that additional call shouldn't make any difference. The problem here is that we simply don't know when __dealloc__() will be called by the Python interpreter. In some cases it might not be called until the interpreter exits, which is fine in most cases, but not if you want to re-open the same port while the interpreter is still running. That's why an additional method is needed to reliably close the server. Dominic |