Commit 5c88a5a0 authored by Vasyl Bodnaruk's avatar Vasyl Bodnaruk

Add update jobs status for running them non stop

parent 2043a712
...@@ -4,18 +4,12 @@ from .service import Service ...@@ -4,18 +4,12 @@ from .service import Service
from .models import Job from .models import Job
@shared_task
def add(x, y):
print('ADDDDDDDDDDDDD')
return x + y
@shared_task @shared_task
def run_job(job_id): def run_job(job_id):
api = Service() api = Service()
api.update_jobs_status()
print('RUN spider', job_id) print('RUN spider', job_id)
job = Job.objects.get(id=job_id) job = Job.objects.get(id=job_id)
print(job)
# run job nonstop # run job nonstop
if job.status == Job.FINISHED and job.interval == Job.NON: if job.status == Job.FINISHED and job.interval == Job.NON:
...@@ -27,9 +21,4 @@ def run_job(job_id): ...@@ -27,9 +21,4 @@ def run_job(job_id):
print('INTERVAL') print('INTERVAL')
api.run_job(job_id) api.run_job(job_id)
# run only one time
elif job.status == Job.PENDING and not job.interval:
print('ONE time')
api.run_job(job_id)
job.schedule_job.delete()
return 'spider was running' return 'spider was running'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment