Answer the question
In order to leave comments, you need to log in
Why doesn't RQ see the module?
Good day. I understand using RQ in conjunction with Flask. Inside the index function, the run function imported from another true.detect.py module is called as a separate task . I ran into an import problem.
I am getting an error:
11:00:50 default: true.detect.run('/home/y700/projects/ultratrue/app/uploads/honey-bee-2-1qf37bs.jpg') (1928a0a3-2051-4951-a57b-dfc2c4992546)
11:00:50 ModuleNotFoundError: No module named 'true'
project
-true
--detect.py
--other files
-app
--app.py
--main.py
basedir = os.path.abspath(os.path.join(os.path.dirname( __file__ )))
app = Flask(__name__)
app.config.from_object(Configuration)
# Added true folder
base = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..'))
sys.path.append(base)
from true.detect import run
#Connect to redis DB
from redis import Redis
from rq import Queue
q = Queue(connection=Redis())
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
.......upload file logic......
img = (os.path.join(app.config['UPLOAD_FOLDER'], filename))
job = q.enqueue(run, img)
if job.is_finished:
return redirect(url_for("result", count=count))
else:
return "Wait"
return render_template("index.html")
job = q.enqueue(run, img)
if job.is_finished:
return redirect(url_for("result", count=count))
else:
return "Wait"
count = run(img)
return redirect(url_for("result", count=count))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question