lilspikey / django-background-task

A database-backed work queue for Django
BSD 3-Clause "New" or "Revised" License
107 stars 200 forks source link

no such table: background_task #14

Open jayata opened 9 years ago

jayata commented 9 years ago

Hi, I'm very new at Django and all the 3rd party app world. I found yours and it seems very easy to use, I installed it, but when I ran an example had got this error "no such table: background_task". I notice that it have its own models.py file but after doing "$ sudo python setup.py install" in my database there is not a "background_task" table created, not even after doing "python manage.py makemigrations" or "syncdb", I'm afraid that I'm missing something. Hope you can help me.

lilspikey commented 9 years ago

Have you added background_task to your INSTALLED_APPS in your settings?

Without that Django won't no to include it when running syncdb.

On 7 July 2015 at 19:16, jayata notifications@github.com wrote:

Hi, I'm very new at Django and all the 3rd party app world. I found yours and it seems very easy to use, I installed it, but when I ran an example had got this error "no such table: background_task". I notice that it have its own models.py file but after doing "$ sudo python setup.py install" in my database there is not a "background_task" table created, not even after doing "python manage.py makemigrations" or "syncdb", I'm afraid that I'm missing something. Hope you can help me.

— Reply to this email directly or view it on GitHub https://github.com/lilspikey/django-background-task/issues/14.

http://psychicorigami.com/

jayata commented 9 years ago

Tanks a lot!! I knew I was missing something basic! Now the task is in the database, but never is executed???? my code is very simple, it just change the value of some variable, nothing else....

@background(schedule=5)
def check():
    #my code here
jayata commented 9 years ago

After running "python manage.py process_tasks" to process the scheduled tasks I got this stack trace:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 160, in run_task
    tasks.run_task(task.task_name, args, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 44, in run_task
    task = self._tasks[task_name]
KeyError: u'main.views.check'
lilspikey commented 9 years ago

It looks like you've defined your task inside you views.py file?

This means that process_tasks can't find it. To ensure it can find it I'd recommend putting it inside tasks.py. You might need to remove that old one from the database too.

This should be covered in the readme:

https://github.com/lilspikey/django-background-task

On 8 July 2015 at 19:53, jayata notifications@github.com wrote:

After running "python manage.py process_tasks" to process the scheduled tasks I got this stack trace:

Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 160, in run_task tasks.run_task(task.task_name, args, kwargs) File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 44, in run_task task = self._tasks[task_name] KeyError: u'main.views.check'

— Reply to this email directly or view it on GitHub https://github.com/lilspikey/django-background-task/issues/14#issuecomment-119695645 .

http://psychicorigami.com/

jayata commented 9 years ago

Yes it was exactly that, sorry English is not my native language..., I really want to get your app working in my project! after your corrections every seems to be OK, but when executed process_tasks throws a warning saying that @transaction.autocommit was deprecated and it must be replaced by set_autocommit, so I did and reinstalled. Now there is no warnings, but mys task is never executed, not even with process_tasks. I saw this issue https://github.com/lilspikey/django-background-task/issues/10 and I noticed that the time in the db is not the same than the machine's. Besides when run process_tasks got this:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/management/commands/process_tasks.py", line 81, in handle
    if not tasks.run_next_task():
  File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 48, in run_next_task
    return self._runner.run_next_task(self)
  File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 173, in run_next_task
    task = self.get_task_to_run()
TypeError: 'NoneType' object is not callable

Thanks for your time...I appreciate it.

lilspikey commented 9 years ago

I think that error is because you have edited the source code and replace @transation.autocommit with something that isn't actually a decorator. That's not the right thing to do.

There is actually a pull request that's meant to be dealing with this:

https://github.com/lilspikey/django-background-task/pull/12

But it's not been merged in yet.

On 9 July 2015 at 15:34, jayata notifications@github.com wrote:

Yes it was exactly that, sorry English is not my native language..., I really want to get your app working in my project! after your corrections every seems to be OK, but when executed process_tasks throws a warning saying that @transaction.autocommit was deprecated and it must be replaced by set_autocommit, so I did and reinstalled. Now there is no warnings, but mys task is never executed, not even with process_tasks. I saw this issue

10 https://github.com/lilspikey/django-background-task/issues/10 and I

noticed that the time in the db is not the same than the machine's. Besides when run process_tasks got this:

Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/init.py", line 385, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/init.py", line 377, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/base.py", line 288, in run_from_argv self.execute(_args, _options.dict) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/base.py", line 338, in execute output = self.handle(_args, _options) File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/management/commands/process_tasks.py", line 81, in handle if not tasks.run_next_task(): File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 48, in run_next_task return self._runner.run_next_task(self) File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 173, in run_next_task task = self.get_task_to_run() TypeError: 'NoneType' object is not callable

Thanks for your time...I appreciate it.

— Reply to this email directly or view it on GitHub https://github.com/lilspikey/django-background-task/issues/14#issuecomment-120003390 .

http://psychicorigami.com/

jayata commented 9 years ago

Thanks, this pull request was very helpful. It works just fine with "python manage.py process_tasks" but the time issue still (the 'run_at' field in the db is about 4 or 5 hours ahead), what should I do?

lilspikey commented 9 years ago

Have you got the right timezone set in your Django settings file?

Reviewing the code it should be calling the right functions to deal with the timezone. It might be that it's storing the times in UTC, rather than your local timezone?

On 13 July 2015 at 15:40, jayata notifications@github.com wrote:

Thanks, this pull request was very helpful. It works just fine with "python manage.py process_tasks" but the time issue still (the 'run_at' field in the db is about 4 or 5 hours ahead), what should I do?

— Reply to this email directly or view it on GitHub https://github.com/lilspikey/django-background-task/issues/14#issuecomment-120952573 .

http://psychicorigami.com/

jayata commented 9 years ago

In my settings.py got this (defaults):

LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True

I'm using Ubuntu and this is the result of the "$ date" command: lun jul 13 15:18:16 CDT 2015 [CDT – Central Daylight Time / Central Daylight Saving Time (Daylight Saving Time)]

This is the task in the db: bd

matthewgo commented 8 years ago

Hello @lilspikey , I'm still getting the error No Such Table: background_task even though I have "background_task" in my INSTALLED_APPS, what other possible reason might have caused it?

lilspikey commented 8 years ago

Have you run syncdb? On 14 May 2016 13:35, "matthewgo" notifications@github.com wrote:

Hello @lilspikey https://github.com/lilspikey , I'm still getting the error No Such Table: background_task even though I have "background_task" in my INSTALLED_APPS, what other possible reason might have caused it?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/lilspikey/django-background-task/issues/14#issuecomment-219218054

matthewgo commented 8 years ago

Please disregard my comment, I reimplemented the entire sequence and now have other problems.

May I first ask what version in Python and Django is this compatible to? I'm using Python 3.4.2 and Django 1.9.6.

Now, what happened was I start receiving errors about package naming issues because apparently the name some import naming convention changed.

I'm doing the following step:

  1. Download the ZIP file, do a setup.py build and setup.py install.
  2. Add background_task to the INSTALLED_APPS
  3. Created tasks.py containing a method with @background annotation and the line inside the method is a print statement.
  4. Call the method in urls.py (just to make sure it will be called) (I think I'm doing something wrong here).
  5. In the command line, run 'python manage.py makemigrations' After this, I received the errors with the import naming conventions.

What steps am I doing wrong? Thanks for the help!

matthewgo commented 8 years ago

After I downloaded the fork version of this project here https://github.com/arteria/django-background-tasks, I am now back with my problem of No Such Table: background_task.

I'm guessing that since I am only referencing an installed app, my project does not know that it should be creating a background_task table for that app, hence outputting "No migrations to apply" when I called 'manage.py makemigrations'. Do you have an idea how to resolve this?

lilspikey commented 8 years ago

I’d take this up with the owners of that fork.

This project currently doesn’t support the latest version of Django. It’s also only meant for Python 2 - not Python 3.

I’m no longer using this project in production, so updates are unlikely for a while.

On 14 May 2016, at 17:55, matthewgo notifications@github.com wrote:

After I downloaded the fork version of this project here https://github.com/arteria/django-background-tasks https://github.com/arteria/django-background-tasks, I am now back with my problem of No Such Table: background_task.

I'm guessing that since I am only referencing an installed app, my project does not know that it should be creating a background_task table for that app, hence outputting "No migrations to apply" when I called 'manage.py makemigrations'. Do you have an idea how to resolve this?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/lilspikey/django-background-task/issues/14#issuecomment-219230952