-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up running spotify instances when removed from configuration (#564) #565
Conversation
@@ -284,6 +284,7 @@ def disconnect(self): | |||
try: | |||
# must use terminate as kill() cannot be intercepted | |||
self._cproc.terminate() | |||
self._cproc.communicate(timeout=5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
terminate()
just fires off a signal; communicate
actually prevents zombies from piling up. Doing things this way can also more appropriately bubble up errors caught during a timeout exception. This was ultimately not the cause of the issue tho, just a worthy improvement.
@@ -511,7 +512,6 @@ def __init__(self, name: str, disabled: bool = False, mock: bool = False): | |||
|
|||
self.connect_port: Optional[int] = None | |||
self.mpris: Optional[MPRIS] = None | |||
self.proc_pid: Optional[int] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unused.
def __del__(self): | ||
self.disconnect() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual bugfix.
self.proc.terminate() | ||
outs, errs = self.proc.communicate(timeout=3) | ||
except Exception as e: | ||
print(f"failed to terminate spotify stream: {e}") | ||
kouts, kerrs = self.proc.kill() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above - just improved process handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes a lot of sense. Should we "robustify" other streams using the terminate/communicate paradigm also?
Nice catch.
This PR fixes #564 , as well as cleans up a couple of things. The bug #564 was that even when a spotify stream was deleted from the configuration, it ran in the background. This was due to the
Spotify(PersistentStream)
class overridingPersistentStream
's__del__
. I've removedSpotify
's__del__
; it appears to be detritus from before it was aPersistentStream
.