job_queue: dont attempt to start a print when empty
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
784b8b9b18
commit
28e88b1363
@ -535,9 +535,9 @@ class FileManager:
|
|||||||
started = True
|
started = True
|
||||||
if self.queue_gcodes and not started:
|
if self.queue_gcodes and not started:
|
||||||
job_queue: JobQueue = self.server.lookup_component('job_queue')
|
job_queue: JobQueue = self.server.lookup_component('job_queue')
|
||||||
started = await job_queue.queue_job(
|
await job_queue.queue_job(
|
||||||
upload_info['filename'], check_exists=False)
|
upload_info['filename'], check_exists=False)
|
||||||
queued = not started
|
queued = True
|
||||||
|
|
||||||
await self.notify_sync_lock.wait(300.)
|
await self.notify_sync_lock.wait(300.)
|
||||||
self.notify_sync_lock = None
|
self.notify_sync_lock = None
|
||||||
|
@ -28,10 +28,10 @@ class JobQueue:
|
|||||||
def __init__(self, config: ConfigHelper) -> None:
|
def __init__(self, config: ConfigHelper) -> None:
|
||||||
self.server = config.get_server()
|
self.server = config.get_server()
|
||||||
self.queued_jobs: Dict[str, QueuedJob] = {}
|
self.queued_jobs: Dict[str, QueuedJob] = {}
|
||||||
self.queue_state: str = "ready"
|
|
||||||
self.lock = asyncio.Lock()
|
self.lock = asyncio.Lock()
|
||||||
self.load_on_start = config.getboolean("load_on_startup", False)
|
self.load_on_start = config.getboolean("load_on_startup", False)
|
||||||
self.automatic = config.getboolean("automatic_transition", False)
|
self.automatic = config.getboolean("automatic_transition", False)
|
||||||
|
self.queue_state: str = "ready" if self.automatic else "paused"
|
||||||
self.job_delay = config.getfloat("job_transition_delay", 0.01)
|
self.job_delay = config.getfloat("job_transition_delay", 0.01)
|
||||||
if self.job_delay <= 0.:
|
if self.job_delay <= 0.:
|
||||||
raise config.error(
|
raise config.error(
|
||||||
@ -150,31 +150,13 @@ class JobQueue:
|
|||||||
|
|
||||||
async def queue_job(self, filename: str,
|
async def queue_job(self, filename: str,
|
||||||
check_exists: bool = True
|
check_exists: bool = True
|
||||||
) -> bool:
|
) -> None:
|
||||||
async with self.lock:
|
async with self.lock:
|
||||||
# Make sure that the file exists
|
# Make sure that the file exists
|
||||||
if check_exists:
|
if check_exists:
|
||||||
self._check_job_file(filename)
|
self._check_job_file(filename)
|
||||||
can_print = await self._check_can_print()
|
|
||||||
if (
|
|
||||||
self.queue_state == "ready" and
|
|
||||||
not self.queued_jobs and
|
|
||||||
can_print
|
|
||||||
):
|
|
||||||
# Printer is ready to accept a print
|
|
||||||
kapis: KlippyAPI = self.server.lookup_component('klippy_apis')
|
|
||||||
try:
|
|
||||||
await kapis.start_print(filename)
|
|
||||||
except self.server.error:
|
|
||||||
# Attempt to start print failed, queue the print
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
if not self.automatic and self.queue_state == "ready":
|
|
||||||
self.queue_state == "paused"
|
|
||||||
queued_job = QueuedJob(filename)
|
queued_job = QueuedJob(filename)
|
||||||
self.queued_jobs[queued_job.job_id] = queued_job
|
self.queued_jobs[queued_job.job_id] = queued_job
|
||||||
return False
|
|
||||||
|
|
||||||
async def pause_queue(self) -> None:
|
async def pause_queue(self) -> None:
|
||||||
self.queue_state = "paused"
|
self.queue_state = "paused"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user