job_queue: add "automatic_transition" option

When set to true, the queue will automatically transition
to the next job in the queue upon completion of the
current job.  When false the queue will pause between
jobs, requiring that the user manually resume.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2021-11-26 16:53:05 -05:00
parent 0b9fa7d87e
commit e8cdd8a928
1 changed files with 3 additions and 2 deletions

View File

@ -31,6 +31,7 @@ class JobQueue:
self.queue_state: str = "ready"
self.lock = asyncio.Lock()
self.load_on_start = config.getboolean("load_on_startup", False)
self.automatic = config.getboolean("automatic_transition", False)
self.job_delay = config.getfloat("job_transition_delay", 0.01)
if self.job_delay <= 0.:
raise config.error(
@ -129,8 +130,8 @@ class JobQueue:
self.queued_jobs.pop(uid, None)
if self.queue_state == "starting":
# If the queue was not paused while starting the print,
# reset state to "ready"
self.queue_state = "ready"
set_ready = not self.queued_jobs or self.automatic
self.queue_state = "ready" if set_ready else "paused"
async def _check_can_print(self) -> bool:
# Query the latest stats