Refactor clearing of queues (Liquidsoap 2)
Currently there are sometimes issues with clearing equeues
(Liquidsoap 1.4.4). For example sometimes clearing the "equeue" results in an infinite loop, telling that the clear is still in progress.
Someone from the Liquidsoap community suggested to solve it with some fragement like this:
Can’t see much in regards to available methods on the returned source in the LS docs of that version for request.equeue as well as request.queue. I’m mostly working with LS 2.x now that there are stable releases of V2 and haven’t done much in-depth stuff before 2.0 so I have no idea if those things are applicable in 1.4.4 too but I doubt it since a lot things have been rewritten / re-architectured. In LS 2.0 there is no request.equeue only request.queue but I think everything that previously was only possible with enqueue is now also possible with queue. The source returned by request.queue has a method named queue which returns () -> [request] so an array of all the requests currently in the queue. You could get the current queue, set it to an empty array and then iterate over all the requests and call request.destroy(r) on them to clear them up. Like this (basic example without testing it):
input_fs = request.queue(id="fs")
def clear_queue(s) =
q = s.queue()
s.set_queue([])
list.iter(request.destroy, q)
end
...
This functionality is only available in Liquidsoap 2.
Meanwhile I found a workaround by activating and deactivating the relevant channel right after clearing. Not sure if there are any side-effects.
Romain (the founder of Liquidsoap) suggested, to definitiely move to Liquidsoap 2.x for our first release, as this is the only actively supported version.