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

django 1.7 stderr exception #336

Closed
brianmay opened this issue Aug 7, 2014 · 6 comments
Closed

django 1.7 stderr exception #336

brianmay opened this issue Aug 7, 2014 · 6 comments

Comments

@brianmay
Copy link

brianmay commented Aug 7, 2014

Hello,

When running with Django 1.7 rc2 and Django wants to report warnings with the database model, it will generate the following error.

(sid)root@aquitard:/tmp/brian/tmpL9WhrO# kg-manage  celery status
Traceback (most recent call last):
  File "/usr/share/python-karaage/bin/kg-manage", line 7, in <module>
    management.execute_from_command_line()
  File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/dist-packages/djcelery/management/commands/celery.py", line 22, in run_from_argv
    self.validate()
  File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 361, in validate
    return self.check(app_configs=app_configs, display_num_errors=display_num_errors)
  File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 415, in check
    self.stderr.write(msg)
AttributeError: 'Command' object has no attribute 'stderr'

This problem will only happen if Django tries to report warnings, if there are no warnings, this will not occur.

As per the following ticket: https://code.djangoproject.com/ticket/23133 django-celery should not call self.validate(), that was a kludge required for earlier Django versions that now breaks Django 1.7.

Thanks

@brianmay brianmay changed the title django 1.7 stderr django 1.7 stderr exception Aug 7, 2014
Karmak23 added a commit to Karmak23/django-celery that referenced this issue Sep 8, 2014
try to avoid self.validate() as suggested in https://code.djangoproject.com/ticket/23133 and celery#336
@Karmak23
Copy link

Karmak23 commented Sep 8, 2014

As you can see in my commit, the fix is easy. commenting the self.validate() calls allow celery to start correctly (and https://github.com/mher/flower too, via django-celery).

@brianmay
Copy link
Author

brianmay commented Sep 8, 2014

I can confirm with @Karmak23 - this is basically the same fix that is in the Debian package.

http://anonscm.debian.org/viewvc/python-modules/packages/django-celery/trunk/debian/patches/remove_validate.patch?revision=30180&view=markup

@brianmay
Copy link
Author

Should also mention that Django 1.7 is released and considered stable; without this change django-celery is broken.

@ask
Copy link
Contributor

ask commented Sep 10, 2014

Hmm, well we can remove it again I guess, but lots of people had problems with models being unavailable when it was disabled

@jpeyret
Copy link

jpeyret commented Nov 12, 2014

Hmmm, maybe this is a dumb suggestion, but... in commands/celery.py, why not set the missing stderr if it's not there? Worked for me.

from sys import stderr
....
class Command(CeleryCommand):
if self.requires_model_validation:
if not hasattr(self, "stderr"):
self.stderr = stderr

self.validate()

Mind you, I have not thought about the ramifications of celery being run as a daemon. Would setting self.stderr to one of the logging module's functions be more appropriate in that case?

@ask
Copy link
Contributor

ask commented Nov 12, 2014

That should work, but not the best solution if you are supposed to be able to override this with a command-line option to manage.py.

It's not a problem for daemonization, because all that happens later, then again if Django 1.7 no longer requires model validation you don't have to change anything.

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

No branches or pull requests

4 participants