Issue #1454 new

Internal error in introspect_management_command. Report it to the author: hynekcer

Paul Walsh
created an issue

I just got this:

Internal error in introspect_management_command. Report it to the author: hynekcer
[('<string>', 1, '<module>', None),
 ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/billiard/forking.py',
  533,
  'main',
  'exitcode = self._bootstrap()'),
 ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/billiard/process.py',
  248,
  '_bootstrap',
  'self.run()'),
 ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/billiard/process.py',
  97,
  'run',
  'self._target(*self._args, **self._kwargs)'),
 ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/billiard/pool.py',
  298,
  'worker',
  'result = (True, func(*args, **kwds))'),
 ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/celery/task/trace.py',
  312,
  '_fast_trace_task',
  'return _tasks[task].__trace__(uuid, args, kwargs, request)[0]'),
 ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/celery/task/trace.py',
  224,
  'trace_task',
  'R = retval = fun(*args, **kwargs)'),
 ('/Users/i/Sites/projects/hamigdalor/project/common/tasks.py',
  15,
  'reindex_search',
  'management.call_command("update_index")'),
 ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/django/core/management/__init__.py',
  150,
  'call_command',
  'return klass.execute(*args, **defaults)'),
 ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/django/core/management/base.py',
  231,
  'execute',
  'self.validate()'),
 ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/django/core/management/base.py',
  266,
  'validate',
  'num_errors = get_validation_errors(s, app)'),
 ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/django/core/management/validation.py',
  96,
  'get_validation_errors',
  'for c in f.choices:'),
 ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/satchmo_utils/iterchoices.py',
  62,
  'iterchoices_db',
  'command = introspect_management_command()'),
 ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/satchmo_utils/iterchoices.py',
  120,
  'introspect_management_command',
  'pprint.pformat(traceback.extract_stack()))')]

I have a task being run by Celery every 15 minutes or so, it is running a Haystack management command:

@task(name="tasks.update_search_index")
def reindex_search():
    print 'DOING REINDEX'
    management.call_command("update_index")

Comments (6)

  1. Hynek Cernoch

    Please verify, that the following patch removes that logged error message for you.

    --- a/satchmo/apps/satchmo_utils/iterchoices.py
    +++ b/satchmo/apps/satchmo_utils/iterchoices.py
    @@ -99,7 +99,7 @@
                     # django.core is usually in '/django/core/' but it can be e.g. in /Django-x.y.z/core/ for some installation
                     if filename.find('/core/management/base.',) >= 0:
                         name = co.co_name
    -                    if name in (('validate', 'handle'), ('execute',), ('run_from_argv',))[nidentify]:
    +                    if name in (('execute', 'validate', 'handle'), ('execute', 'validate'), ('run_from_argv',))[nidentify]:
                             nidentify += 1
                             # analyze first argument of execute(self, *args, **options)
                             if name == 'execute' and co.co_argcount == 1 and (co.co_flags & 0xC == 0xC):
    

    Thank you for the report. Your error message is not a serious bug in the case of "update_index" command. It only means that some introspection code is not updated for some new context of usage with some Django version. (version Django 1.4 in your case without manage.py) Introspection is important only for #1256 and #1348 (syncdb or migrate). I prefer reporting and fixing of unclear cases more often over waiting for a mysterious bug repeated again.

  2. Paul Walsh reporter

    Again, with your patch, this is the error:

    Internal error in introspect_management_command. Report it to the author: hynekcer [('<string>', 1, '<module>', None), ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/billiard/forking.py', 533, 'main', 'exitcode = self._bootstrap()'), ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/billiard/process.py', 248, '_bootstrap', 'self.run()'), ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/billiard/process.py', 97, 'run', 'self._target(self._args, self._kwargs)'), ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/billiard/pool.py', 298, 'worker', 'result = (True, func(*args, kwds))'), ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/celery/task/trace.py', 312, '_fast_trace_task', 'return _tasks[task].trace(uuid, args, kwargs, request)[0]'), ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/celery/task/trace.py', 224, 'trace_task', 'R = retval = fun(args, kwargs)'), ('/Users/i/Sites/projects/hamigdalor/project/common/tasks.py', 30, 'backup_to_json', "management.call_command('dumpdata')"), ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/django/core/management/__init__.py', 150, 'call_command', 'return klass.execute(*args, defaults)'), ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/django/core/management/base.py', 231, 'execute', 'self.validate()'), ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/django/core/management/base.py', 266, 'validate', 'num_errors = get_validation_errors(s, app)'), ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/django/core/management/validation.py', 96, 'get_validation_errors', 'for c in f.choices:'), ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/satchmo_utils/iterchoices.py', 62, 'iterchoices_db', 'command = introspect_management_command()'), ('/Users/i/Sites/environments/hamigdalor/lib/python2.7/site-packages/satchmo_utils/iterchoices.py', 120, 'introspect_management_command', 'pprint.pformat(traceback.extract_stack()))')]

  3. Jonathan Stoppani

    In my case, I am executing some code inside a uWSGI cron task. I think that uWSGI runs these tasks in a different context and no management command is thus found during introspection.

    What about adding a simple test for this case?

  4. Log in to comment