OpenCRE icon indicating copy to clipboard operation
OpenCRE copied to clipboard

Import Error from rq when trying to spin up a worker

Open vfxcode opened this issue 1 year ago • 5 comments

It seems there is an issue when we try to spin up a worker. The following error occurs:

root@cb1fe159a166:/code# FLASK_APP=`pwd`/cre.py python cre.py --start_worker
Traceback (most recent call last):
  File "/code/cre.py", line 244, in <module>
    main()
  File "/code/cre.py", line 240, in main
    cre_main.run(args)
  File "/code/application/cmd/cre_main.py", line 631, in run
    from application.worker import start_worker
  File "/code/application/worker.py", line 3, in <module>
    from rq import Worker, Queue, Connection
ImportError: cannot import name 'Connection' from 'rq' (/usr/local/lib/python3.11/site-packages/rq/__init__.py)

We have validated that OpenCRE has a fully functioning Redis and OpenCRE is correctly configured to connect to it. We can after all see the jobs get queued in the respective redis keys.

vfxcode avatar Feb 18 '25 11:02 vfxcode

hi @vfxcode Issue: Getting ImportError: cannot import name 'Connection' from 'rq' when trying to spin up the worker.

Steps Taken to Fix:

  1. Checked the installed rq version.
  2. Removed the deprecated Connection import.
  3. Used Redis for connection instead.
  4. Initialized the worker with the correct Redis connection.
  5. Tested and confirmed the worker is running successfully.

Next Steps:

Should we update the dependencies or document this change to prevent future issues? Let me know your thoughts!

Hardik301002 avatar Mar 12 '25 19:03 Hardik301002

Hey thank you for taking a look, yes please go ahead!

On Wed, 12 Mar 2025, 19:49 @., @.> wrote:

hi @vfxcode https://github.com/vfxcode Issue: Getting ImportError: cannot import name 'Connection' from 'rq' when trying to spin up the worker.

Steps Taken to Fix:

  1. Checked the installed rq version.
  2. Removed the deprecated Connection import.
  3. Used Redis for connection instead.
  4. Initialized the worker with the correct Redis connection.
  5. Tested and confirmed the worker is running successfully.

Next Steps:

Should we update the dependencies or document this change to prevent future issues? Let me know your thoughts!

— Reply to this email directly, view it on GitHub https://github.com/OWASP/OpenCRE/issues/582#issuecomment-2718936613, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMCRHSHOMN7U3UCPZUA6E32UCFVVAVCNFSM6AAAAABXLLV7AKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJYHEZTMNRRGM . You are receiving this because you are subscribed to this thread.Message ID: @.***> [image: Hardik301002]Hardik301002 left a comment (OWASP/OpenCRE#582) https://github.com/OWASP/OpenCRE/issues/582#issuecomment-2718936613

hi @vfxcode https://github.com/vfxcode Issue: Getting ImportError: cannot import name 'Connection' from 'rq' when trying to spin up the worker.

Steps Taken to Fix:

  1. Checked the installed rq version.
  2. Removed the deprecated Connection import.
  3. Used Redis for connection instead.
  4. Initialized the worker with the correct Redis connection.
  5. Tested and confirmed the worker is running successfully.

Next Steps:

Should we update the dependencies or document this change to prevent future issues? Let me know your thoughts!

— Reply to this email directly, view it on GitHub https://github.com/OWASP/OpenCRE/issues/582#issuecomment-2718936613, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMCRHSHOMN7U3UCPZUA6E32UCFVVAVCNFSM6AAAAABXLLV7AKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJYHEZTMNRRGM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

northdpole avatar Mar 13 '25 22:03 northdpole

Hi! I noticed @Hardik301002 hasn't submitted a PR for this yet. I'd like to take this on, I can implement the fix and update the dependencies accordingly..

rashmivemuri avatar Mar 19 '26 21:03 rashmivemuri

@rashmivemuri Please go ahead and make sure to test everything !

Pa04rth avatar Mar 20 '26 06:03 Pa04rth

Hi! After investigating the codebase, I found that the Connection import has already been removed from worker.py and the worker initialization has been updated to pass the connection directly to Worker. The original issue appears to be resolved in the current code. I'd suggest closing this issue unless there are additional test cases needed...

rashmivemuri avatar Mar 24 '26 20:03 rashmivemuri