0

I have a very strange problem since a few hours with what seems really two really unrelated things: a Systemd service (doing nothing!) and the listing of available audio devices.

More precisely I have a service /etc/systemd/system/myservice.service which runs as soon as possible on boot:

[Unit]
Description=Test
DefaultDependencies=false
[Service]
Type=simple
ExecStart=/usr/bin/python /root/foo.py
WorkingDirectory=/root/
[Install]
WantedBy=local-fs.target

foo.py simply queries the audio devices with the sounddevice Python module (wrapper around PortAudio):

import sounddevice
print(sounddevice.query_devices(0))

This perfectly works and returns 1 audio device.

However, when I add a second service /etc/systemd/system/[email protected] that does really nothing (initially it did mount the USB devices with this solution, but I even removed this part to do the debugging, and the problem is still there!):

[Unit]
Description=Mount USB Drive on %i
[Service]
Type=simple
ExecStart=/usr/bin/ls         # note: normally here we should automount USB devices, but the bug is still there with just a simple ls that does nothing!

which is started by this udev rule /etc/udev/rules.d/99-local.rules:

KERNEL=="sd[a-z][0-9]", SUBSYSTEMS=="usb", ACTION=="add", RUN+="/bin/systemctl start usb-mount@%k.service"

... then the querying of audio devices fails with:

Dec 10 22:51:27 foo foo.sh[116]:   File "/usr/local/lib/python2.7/dist-packages/sounddevice.py", line 778, in __init__
Dec 10 22:51:27 foo foo.sh[116]:     extra_settings, samplerate)
Dec 10 22:51:27 foo foo.sh[116]:   File "/usr/local/lib/python2.7/dist-packages/sounddevice.py", line 2571, in _get_stream_parameters
Dec 10 22:51:27 foo foo.sh[116]:     info = query_devices(device)
Dec 10 22:51:27 foo foo.sh[116]:   File "/usr/local/lib/python2.7/dist-packages/sounddevice.py", line 569, in query_devices
Dec 10 22:51:27 foo foo.sh[116]:     raise PortAudioError('Error querying device {0}'.format(device))
Dec 10 22:51:27 foo foo.sh[116]: sounddevice.PortAudioError: Error querying device 0
Dec 10 22:51:27 foo systemd[1]: foo.service: Main process exited, code=exited, status=1/FAILURE
Dec 10 22:51:27 foo systemd[1]: foo.service: Failed with result 'exit-code'.

How to debug this problem? The fact that PortAudio is able to query informations about an audio device should be totally unrelated to this second Systemd service (started by udev) which does really nothing, don't you think so?

I am really clueless about this bug linking two totally unrelated things.


Note: removing DefaultDependencies=false seems to solve the problem. But I thought DefaultDependencies=false was necessary to avoid the service to wait for networking to be ready before starting. Is there another solution without this option?

2

0

You must log in to answer this question.

Browse other questions tagged .