# Mopidy with http enabled hangs at shutdown

**URL:** <https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745>\
**Category:** Misc\
**Created:** [September 4, 2018, 5:23pm UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745 "2018-09-04T17:23:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![MHoyer12345678](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/mhoyer12345678/32/988_2.png) [@MHoyer12345678](https://discourse.mopidy.com/u/MHoyer12345678)\
**Post date:** [September 4, 2018, 5:23pm UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/1 "2018-09-04T17:23:52Z")

</div>

Hello,

I’m new here. Hope this is the right way to get some hints on an issue I’m observing currently.

What am I doing:  
I’m creating a Linux Firmware with Mopidy and Rygel on it for an old radio (the ones from the 1920s) using a raspberry pi zero w. The radio should be able to play internet radio and to play music from phones in the local wifi. So after some trials, I decided to use mopidy as player together with tunein for the radio and to connect it via mpris with rygel for the dlna playbacks.

What’s already working:  
The basic functionality is working fine, internet radio and dlna playback. I’m now working on a safe shutdown using the persistent state functionality of mopidy.

What’s the problem:  
In my environment (later some words to it), I cannot stop mopidy using SIGTERM properly. I analyzed it a bit and found that the main function of mopidy is actually left but the process seems to stay alive probably due to another thread not being stopped (just an assumption). This behaviour can be only observed when the http extension is active. So I guess this extension is not shutting down properly. I checked the “stop\_remaining\_actor()” function and found that this is left properly without any actor being still alive. Any idea?

To the environment:  
I boot strapped a minimal raspian with just in it what is needed. Rygel and mopidy are connected via a session dbus created using systemd service files. Connman is used to create a wifi connection to my wifi router. Another network interface is configured with a network ip but it is not connected.

Would be nice to get some feedback on how to analyze further the issues.

Thx in advance,

Marko

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [September 4, 2018, 6:03pm UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/2 "2018-09-04T18:03:45Z")

</div>

Does a debug log help at all? Can you provide it?

---

<div class="post-metadata">

**Author:** ![MHoyer12345678](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/mhoyer12345678/32/988_2.png) [@MHoyer12345678](https://discourse.mopidy.com/u/MHoyer12345678)\
**Post date:** [September 4, 2018, 7:37pm UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/3 "2018-09-04T19:37:39Z")

</div>

Hello,

I captured the logs. Find them here:  
[http://www.informatik.uni-oldenburg.de/~joemal/start.log](http://www.informatik.uni-oldenburg.de/~joemal/start.log)  
[http://www.informatik.uni-oldenburg.de/~joemal/stop.log](http://www.informatik.uni-oldenburg.de/~joemal/stop.log)

Looks not helpful to me. Any additional ideas?

Thx!  
Marko

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [September 4, 2018, 8:39pm UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/4 "2018-09-04T20:39:50Z")

</div>

I don’t really understand that log. Why is systemd timing out after only 2 seconds? Where is it hanging?

---

<div class="post-metadata">

**Author:** ![MHoyer12345678](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/mhoyer12345678/32/988_2.png) [@MHoyer12345678](https://discourse.mopidy.com/u/MHoyer12345678)\
**Post date:** [September 5, 2018, 5:49am UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/5 "2018-09-05T05:49:49Z")

</div>

Hi,

I called systemctl stop to stop mopidy. This way, systemd sends SIGTERM and waits until this process exists. If it does not exit after a certain timeout, it sends SIGKILL to finally stop the process. The default timeout is set to 2min, I set it to 2secs for mopidy.

Marko

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [September 5, 2018, 7:22am UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/6 "2018-09-05T07:22:51Z")

</div>

If you put it back to the default (90 seconds on my system), you don’t see anything more in the debug log?

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [September 5, 2018, 7:58am UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/7 "2018-09-05T07:58:21Z")

</div>

Can you also provide the output of `sudo mopidyctl deps`.

---

<div class="post-metadata">

**Author:** ![MHoyer12345678](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/mhoyer12345678/32/988_2.png) [@MHoyer12345678](https://discourse.mopidy.com/u/MHoyer12345678)\
**Post date:** [September 5, 2018, 8:00am UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/8 "2018-09-05T08:00:06Z")

</div>

Nope 😉 the last three error logs are added by me in the stop\_… Function. If I got the code right, nothing happens after this function anymore despite a few returns so i assume the main function is left…

---

<div class="post-metadata">

**Author:** ![MHoyer12345678](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/mhoyer12345678/32/988_2.png) [@MHoyer12345678](https://discourse.mopidy.com/u/MHoyer12345678)\
**Post date:** [September 5, 2018, 8:01am UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/9 "2018-09-05T08:01:53Z")

</div>

To mopidyctl: ok, i’m at work currently. I’ll captue the output this evening…

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [September 5, 2018, 10:06am UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/10 "2018-09-05T10:06:31Z")

</div>

You could try running `top -H -p $(pgrep mopidy)` and then watch what happens when you send SIGTERM? Chances are it’ll just be one of the unnamed threads but worth a go.

---

<div class="post-metadata">

**Author:** ![MHoyer12345678](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/mhoyer12345678/32/988_2.png) [@MHoyer12345678](https://discourse.mopidy.com/u/MHoyer12345678)\
**Post date:** [September 5, 2018, 7:53pm UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/11 "2018-09-05T19:53:22Z")

</div>

Hi,

mopidyctl deps says:

Running “/usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf deps” as user mopidy  
Executable: /usr/bin/mopidy  
Platform: Linux-4.14.49-v7±armv7l-with-debian-buster-sid  
Python: CPython 2.7.15 from /usr/lib/python2.7  
Mopidy: 2.1.0 from /usr/lib/python2.7/dist-packages  
Mopidy-MPRIS: 1.4.0 from /usr/lib/python2.7/dist-packages  
Mopidy-Mobile: 1.8.3 from /usr/local/lib/python2.7/dist-packages  
setuptools: 39.2.0 from /usr/lib/python2.7/dist-packages  
Mopidy\>=0.19: 2.1.0 from /usr/lib/python2.7/dist-packages  
Mopidy-TuneIn: 0.4.1 from /usr/lib/python2.7/dist-packages  
GStreamer: 1.14.2.0 from /usr/lib/python2.7/dist-packages/gi  
Detailed information:  
Python wrapper: python-gi 3.28.3  
Relevant elements:  
Found:  
uridecodebin  
souphttpsrc  
appsrc  
alsasink  
osssink  
oss4sink  
pulsesink  
id3demux  
id3v2mux  
lamemp3enc  
mpegaudioparse  
mpg123audiodec  
vorbisdec  
vorbisenc  
vorbisparse  
oggdemux  
oggmux  
oggparse  
flacdec  
flacparse  
shout2send  
Not found:  
flump3dec  
mad

Marko

---

<div class="post-metadata">

**Author:** ![MHoyer12345678](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/mhoyer12345678/32/988_2.png) [@MHoyer12345678](https://discourse.mopidy.com/u/MHoyer12345678)\
**Post date:** [September 5, 2018, 8:04pm UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/12 "2018-09-05T20:04:30Z")

</div>

Hi again,

with top, one can observe that three threads remain after SIGTERM.

At runtime:  
555 mopidy 20 0 143648 36512 13964 S 0.0 3.8 0:03.33 mopidy  
562 mopidy 20 0 143648 36512 13964 S 0.0 3.8 0:00.00 gmain  
563 mopidy 20 0 143648 36512 13964 S 0.0 3.8 0:00.01 mopidy  
564 mopidy 20 0 143648 36512 13964 S 0.0 3.8 0:00.05 mopidy  
565 mopidy 20 0 143648 36512 13964 S 0.0 3.8 0:00.00 mopidy  
566 mopidy 20 0 143648 36512 13964 S 0.0 3.8 0:00.01 mopidy  
567 mopidy 20 0 143648 36512 13964 S 0.0 3.8 0:00.00 mopidy  
568 mopidy 20 0 143648 36512 13964 S 0.0 3.8 0:00.00 mopidy  
569 mopidy 20 0 143648 36512 13964 S 0.0 3.8 0:00.01 mopidy  
571 mopidy 20 0 143648 36512 13964 S 0.0 3.8 0:00.01 mopidy

After SIGTERM:  
555 mopidy 20 0 102840 36688 13964 S 0.0 3.9 0:03.37 mopidy  
562 mopidy 20 0 102840 36688 13964 S 0.0 3.9 0:00.00 gmain  
572 mopidy 20 0 102840 36688 13964 S 0.0 3.9 0:00.01 mopidy

Interestingly, a thread is active that is not there during normal run (TID 572).

Marko

---

<div class="post-metadata">

**Author:** ![schinkelg](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@schinkelg](https://discourse.mopidy.com/u/schinkelg)\
**Post date:** [September 7, 2018, 8:05am UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/13 "2018-09-07T08:05:03Z")

</div>

I’m experiencing this as well. Systemctl is only able to kill it after my 90 second (default) timeout. Killing it by hand with kill -9 of course works, but is a hassle.

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [September 7, 2018, 9:17am UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/14 "2018-09-07T09:17:28Z")

</div>

Can you confirm that disabling the http frontend also fixes it?

---

<div class="post-metadata">

**Author:** ![schinkelg](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@schinkelg](https://discourse.mopidy.com/u/schinkelg)\
**Post date:** [September 7, 2018, 9:40am UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/15 "2018-09-07T09:40:50Z")

</div>

YES! That brought it down to 9 seconds, which is workable. Thank you very much.

> time systemctl stop mopidy

real 0m8.927s  
user 0m0.005s  
sys 0m0.005s

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [September 7, 2018, 10:39am UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/16 "2018-09-07T10:39:24Z")

</div>

Can you provide the full output please, @MHoyer12345678. I want to know what Tornado version you have.

---

<div class="post-metadata">

**Author:** ![MHoyer12345678](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/mhoyer12345678/32/988_2.png) [@MHoyer12345678](https://discourse.mopidy.com/u/MHoyer12345678)\
**Post date:** [September 7, 2018, 10:47am UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/17 "2018-09-07T10:47:04Z")

</div>

Which output do you need?

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [September 7, 2018, 11:23am UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/18 "2018-09-07T11:23:12Z")

</div>

The `mopidyctl deps` output.

---

<div class="post-metadata">

**Author:** ![MHoyer12345678](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/mhoyer12345678/32/988_2.png) [@MHoyer12345678](https://discourse.mopidy.com/u/MHoyer12345678)\
**Post date:** [September 7, 2018, 8:44pm UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/19 "2018-09-07T20:44:35Z")

</div>

Hello,

the output I sent was the complete output I got from mopidyctl deps.

Anyway, following tornado version is installed in my system:

root@svens-radio:/home/joe# pip list | grep tornado  
tornado (5.0.2)

Regards,

Marko

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [September 7, 2018, 9:21pm UTC](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745/20 "2018-09-07T21:21:54Z")

</div>

That’s very odd.

We don’t test with Tornado v5.0 so it’s possible there’s some problems with it. Could you try downgrading to something between v4.4 and v5?

[Next page](https://discourse.mopidy.com/t/mopidy-with-http-enabled-hangs-at-shutdown/2745.md?page=2)
