question

ralfz avatar image
ralfz asked

How to kill a dbus service from within a python script?

I am running a python script which serves as a watchdog for a dbus service also written in python. The watchdog script should kill the dbus service when certain criteria exist - this would result in the service being restartet by the supervise.
With VenusOS v2.60 running on the Raspi 3B, I was using this python line to kill the dbus service:

os.system("kill $(pgrep -f 'python /data/dbus-myservice/dbus-myservice.py')")

Now, after the update to VenusOS v2.66, I notice that this command does not work anymore.

What has changed?
What is he recommended way to kill a dbus service from within another python script?

Venus OS
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

1 Answer
Kevin Windrem avatar image
Kevin Windrem answered Ā·

not sure why this isn't working when it did before.


If your dbus service is run as a service, then you can cause it to quit and restart with:

os.system (svc -t /service/<service directory name>)

You could also write the main python program to exit under the criteria the watchdog service is testing for. supervise would then restart the main program.


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources