Catch luampd socket error and reconnect
This commit is contained in:
parent
c56bbec1db
commit
e37b2d3403
2 changed files with 3 additions and 4 deletions
3
mpd.lua
3
mpd.lua
|
@ -36,7 +36,8 @@ M.disconnect = function()
|
|||
end
|
||||
|
||||
M.ensure_connection = function()
|
||||
if conn == nil then M.connect() end
|
||||
-- luampd throws SOCKET_ERRORs all the time. catch them and reconnect
|
||||
if conn == nil or not pcall(conn:status()) then M.connect() end
|
||||
end
|
||||
|
||||
-- }}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue