Coverage for src/couchers/jobs/enqueue.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-11-21 04:21 +0000

1""" 

2Background jobs 

3""" 

4 

5import logging 

6 

7from couchers.models import BackgroundJob 

8 

9logger = logging.getLogger(__name__) 

10 

11 

12def queue_job(session, job_type: str, payload, max_tries=None): 

13 job = BackgroundJob( 

14 job_type=job_type, 

15 payload=payload.SerializeToString(), 

16 max_tries=max_tries, 

17 ) 

18 session.add(job) 

19 return job.id