Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I remove a job from the scheduler #20

Closed
hhyo opened this issue Apr 28, 2018 · 4 comments
Closed

When I remove a job from the scheduler #20

hhyo opened this issue Apr 28, 2018 · 4 comments
Labels

Comments

@hhyo
Copy link

hhyo commented Apr 28, 2018

  • env:
    Django==1.8.17
    django-apscheduler==0.2.7

  • code:

job_id=test
scheduler.add_job(_execute_job, 'date', run_date=run_date, args=[workflowId, url], id=job_id,
                          replace_existing=True)
scheduler.remove_job(job_id)
  • traceback:
[2018-04-28 21:44:50,884][Thread-22:123145460006912][task_id:default][exception_logging_middleware.py:10] [ERROR]- Traceback (most recent call last):
  File "/Users/lihuanhuan/PycharmProjects/venv4archer/lib/python3.6/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/lihuanhuan/PycharmProjects/archer-github/sql/views.py", line 410, in cancel
    del_sqlcronjob(job_id)
  File "/Users/lihuanhuan/PycharmProjects/archer-github/sql/jobs.py", line 53, in del_sqlcronjob
    return scheduler.remove_job(job_id)
  File "/Users/lihuanhuan/PycharmProjects/venv4archer/lib/python3.6/site-packages/apscheduler/schedulers/base.py", line 608, in remove_job
    store.remove_job(job_id)
  File "/Users/lihuanhuan/PycharmProjects/venv4archer/lib/python3.6/site-packages/django_apscheduler/jobstores.py", line 27, in inner
    return func(*a, **k)
  File "/Users/lihuanhuan/PycharmProjects/venv4archer/lib/python3.6/site-packages/django_apscheduler/jobstores.py", line 117, in remove_job
    deleted, _ = DjangoJob.objects.filter(name=job_id).delete()
TypeError: 'NoneType' object is not iterable

  • jobstores.py", line 117
    @ignore_database_error
    def remove_job(self, job_id):
        deleted, _ = DjangoJob.objects.filter(name=job_id).delete() 
        if deleted == 0:
            raise JobLookupError(job_id)
@sallyruthstruik
Copy link
Collaborator

sallyruthstruik commented Apr 28, 2018

Interesting bug! Thank you! Looks like Django 1.11 and django 1.8 have different return values for .delete method. Will provide fix right now

@sallyruthstruik
Copy link
Collaborator

@sallyruthstruik
Copy link
Collaborator

please, check that everything is ok and give feedback to allow me close the issue

@hhyo
Copy link
Author

hhyo commented Apr 29, 2018

Everything is ok! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants