Python Celery worker_main "RuntimeError: Maximum recursion depth exceeded"
I am working on a Celery based application and want to initiate workers from the main function. Here's a very simplified version of the code:
from celery import Celery
class CoolApp(object):
def __init__(self):
self.app = Celery('test', 'amqp://guest@localhost/')
test = CoolApp()
test.app.worker_main()
This throws an error RuntimeError: maximum recursion depth exceeded in cmp
and I can't figure out why. Please, help.
Traceback:
Traceback (most recent call last):
File "test.py", line 9, in <module>
test.app.worker_main()
File "/usr/lib/python2.7/site-packages/celery/app/base.py", line 368, in worker_main
).execute_from_commandline(argv)
File "/usr/lib/python2.7/site-packages/celery/bin/base.py", line 281, in execute_from_commandline
return self.handle_argv(self.prog_name, argv[1:])
File "/usr/lib/python2.7/site-packages/celery/bin/base.py", line 367, in handle_argv
*self.parse_options(prog_name, argv, command))
File "/usr/lib/python2.7/site-packages/celery/bin/base.py", line 403, in parse_options
self.parser = self.create_parser(prog_name, command)
File "/usr/lib/python2.7/site-packages/celery/bin/base.py", line 419, in create_parser
self.add_arguments(parser)
File "/usr/lib/python2.7/site-packages/celery/bin/worker.py", line 275, in add_arguments
default=conf.worker_state_db,
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 431, in __getitem__
return getitem(k)
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 280, in __getitem__
return mapping[_key]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
...
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/celery/utils/collections.py", line 130, in __getattr__
return self[k]
File "/usr/lib64/python2.7/UserDict.py", line 19, in __getitem__
if key in self.data:
File "/usr/lib/python2.7/site-packages/kombu/utils/objects.py", line 44, in __get__
value = obj.__dict__[self.__name__] = self.__get(obj)
File "/usr/lib/python2.7/site-packages/celery/app/base.py", line 148, in data
return self.callback()
File "/usr/lib/python2.7/site-packages/celery/app/base.py", line 910, in _finalize_pending_conf
conf = self._conf = self._load_config()
File "/usr/lib/python2.7/site-packages/celery/app/base.py", line 923, in _load_config
self.prepare_config(self.loader.conf), self._preconf,
File "/usr/lib/python2.7/site-packages/kombu/utils/objects.py", line 44, in __get__
value = obj.__dict__[self.__name__] = self.__get(obj)
File "/usr/lib/python2.7/site-packages/celery/app/base.py", line 1208, in loader
return get_loader_cls(self.loader_cls)(app=self)
File "/usr/lib/python2.7/site-packages/celery/loaders/__init__.py", line 21, in get_loader_cls
return symbol_by_name(loader, LOADER_ALIASES, imp=import_from_cwd)
File "/usr/lib/python2.7/site-packages/kombu/utils/imports.py", line 56, in symbol_by_name
module = imp(module_name, package=package, **kwargs)
File "/usr/lib/python2.7/site-packages/celery/utils/imports.py", line 100, in import_from_cwd
with cwd_in_path():
File "/usr/lib64/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/lib/python2.7/site-packages/celery/utils/imports.py", line 60, in cwd_in_path
if cwd in sys.path:
RuntimeError: maximum recursion depth exceeded in cmp
+3
source to share
1 answer
I got the same error when I tried to upgrade celery from 3.1.25 to 4.1.0. So basically in 4.1.0 a few packages are deprecated. So make sure you are not using classes that are deprecative in the latest version. In my case I am using celery.worker.job.Request which was deprecated in 3.1.25 and now it is celery.worker.request.Request
Hope this helps you.
0
source to share