Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask + Celery + Docker Compose Up Error: AttributeError: 'cached_property' object has no attribute 'lock'

I am attempting to follow the tutorial below, but I ran into an issue with "docker compose up". I don't have the first clue on why I am receiving "AttributeError: 'cached_property' object has no attribute 'lock'" Would anyone be able to direct me here? I keep searching the internet but nothing I find has really provided me much direction so far.

Tutorial: https://www.youtube.com/watch?v=2j3em0QQaMg Tutorial Github: https://github.com/PrettyPrinted/youtube_video_code/tree/master/2023/01/27/An%20Example%20of%20Celery%20in%20a%20Flask%20App%20With%20Multiple%20Files

Web1 Code1: Traceback (most recent call last):

File "/usr/local/bin/flask", line 8, in <module>
   sys.exit(main())
            ^^^^^^
 File "/usr/local/lib/python3.12/site-packages/flask/cli.py", line 1064, in main
   cli.main()
 File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1078, in main
   rv = self.invoke(ctx)
        ^^^^^^^^^^^^^^^^
 File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
   return _process_result(sub_ctx.command.invoke(sub_ctx))
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
   return ctx.invoke(self.callback, **ctx.params)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/local/lib/python3.12/site-packages/click/core.py", line 783, in invoke
   return __callback(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/local/lib/python3.12/site-packages/click/decorators.py", line 92, in new_func
   return ctx.invoke(f, obj, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/local/lib/python3.12/site-packages/click/core.py", line 783, in invoke
   return __callback(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/local/lib/python3.12/site-packages/flask/cli.py", line 912, in run_command
   raise e from None
 File "/usr/local/lib/python3.12/site-packages/flask/cli.py", line 898, in run_command
   app = info.load_app()
         ^^^^^^^^^^^^^^^
 File "/usr/local/lib/python3.12/site-packages/flask/cli.py", line 309, in load_app
   app = locate_app(import_name, name)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/local/lib/python3.12/site-packages/flask/cli.py", line 219, in locate_app
   __import__(module_name)
 File "/app/run.py", line 3, in <module>
   app, celery = create_app()
                 ^^^^^^^^^^^^
 File "/app/project/__init__.py", line 16, in create_app
   celery = make_celery(app)
            ^^^^^^^^^^^^^^^^
 File "/app/project/utils.py", line 12, in make_celery
   celery.Task = ContextTask
   ^^^^^^^^^^^
 File "/usr/local/lib/python3.12/site-packages/kombu/utils/objects.py", line 37, in __set__
   with self.lock:
        ^^^^^^^^^

AttributeError: 'cached_property' object has no attribute 'lock'

Celery1 Code 2: Usage: celery [OPTIONS] COMMAND [ARGS]... Try 'celery --help' for help.

Error: Invalid value for '-A' / '--app': Unable to load celery application. 'cached_property' object has no attribute 'lock' exited with code 2

I have searched Stackoverflow and other help sites but any answers I have found don't seem to match up enough for me to gain insight into a solution.

like image 648
Sat Lab Avatar asked Sep 07 '26 09:09

Sat Lab


2 Answers

This is known issue on python 3.12, see: https://github.com/celery/kombu/issues/1804

like image 110
Roland Kainrath Avatar answered Sep 10 '26 03:09

Roland Kainrath


I had the same problem when I was using python 3.12, I changed my python version to 3.11 and the problem solved.

like image 39
Omid Koochaki Avatar answered Sep 10 '26 03:09

Omid Koochaki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!