INNER CODE UNIT · Python
_next_job_id
MichielMe/fastscheduler · src/fastscheduler/main.py:231
def _next_job_id(self) -> str:
"""Generate next job ID (thread-safe)."""
self._job_counter_value = next(self._job_counter)
return f"job_{self._job_counter_value}"
def _add_job(self, job: Job):
"""Add job to the priority queue."""
with self.lock:
if any(j.job_id == job.job_id for j in self.jobs):
logger.warning(f"Job {job.job_id} already exists, skipping")
return
heapq.heappush(self.jobs, job)
self._log_history(job.job_id, job.func_name, JobStatus.SCHEDULED)
schedule_desc = job.get_schedule_description()
if not self.quiet:
logger.info(f"Scheduled: {job.func_name} - {schedule_desc}")