У меня есть приложение python flask, которое запускает команду оболочки, и оно обрабатывается потоком для обработки процесса syn c.
def _upload_video_firebase(self, f1, f2, output_filename):
t = threading.Thread(target=self._download_video, args=(f1,f2,output_filename,))
print('threading')
t.daemon = True
t.start()
# t.join()
def overlay_video(self, f1,f2, output_filename):
print('processing video')
start_time = time.time()
f1 = "'" + f1 + "'"
f2 = 'API/video/input/{0}'.format(f2)
if not os.path.exists('API/video/output'):
os.makedirs('API/video/output')
succ = True
cmd=('ffmpeg -i {0} -vf "movie= {1} [a]; [in][a]overlay=0:0 [c]" API/video/output/{2} '.format(f1,f2,output_filename))
print(cmd)
try:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
stdoutdata, stderrdata = p.communicate()
if p.wait() != 0:
# Handle error / raise exception
succ = False
print ("There were some errors")
print(stderrdata)
return succ
print('conversion success')
file_path = 'API/video/output/{0}'.format(output_filename)
succ = self.client.upload_video(file_path)
print(succ)
print("code_exc_time %s" % (time.time() - start_time))
if succ:
self.delete_file(file_path)
return succ
except OSError as e:
errors = True
print(e.strerror)
# return e.strerror, errors
def delete_file(self, file_path):
if os.path.exists(file_path):
print('deleted {0}'.format(file_path))
os.remove(file_path)
Поток работает нормально, когда я использую команду run flask без docker. Docker file
FROM tiangolo/uwsgi-nginx-flask:python3.7
# Indicate where uwsgi.ini lives
ENV UWSGI_INI uwsgi.ini
# Tell nginx where static files live.
ENV STATIC_URL /app/static
ENV PYTHONUNBUFFERED=1
# Set the folder where uwsgi looks for the app
WORKDIR /app
# If you have additional requirements beyond Flask (which is included in the
# base image), generate a requirements.txt file with pip freeze and uncomment
# the next three lines.
COPY API/requirements.txt /app/API/
RUN pip install --no-cache-dir -U pip
RUN pip install --no-cache-dir -r /app/API/requirements.txt
RUN apt-get update -y
RUN apt-get install ffmpeg -y
# Copy the app contents to the image
COPY ./ /app
#ENV PORT 8080
Но когда я запускаю это с docker, это зависает при обработке оболочки cmd. Но когда я убиваю docker, я вижу процесс ex c su cc.
Пожалуйста, помогите, это довольно сложно.