moduleGitlab# JobWaiter can be used to wait for a number of Sidekiq jobs to complete.classJobWaiter# The sleep interval between checking keys, in seconds.INTERVAL=0.1# jobs - The job IDs to wait for.definitialize(jobs)@jobs=jobsend# Waits for all the jobs to be completed.## timeout - The maximum amount of seconds to block the caller for. This# ensures we don't indefinitely block a caller in case a job takes# long to process, or is never processed.defwait(timeout=60)start=Time.currentwhile(Time.current-start)<=timeoutbreakifSidekiqStatus.all_completed?(@jobs)sleep(INTERVAL)# to not overload Redis too much.endendendend