728x90

Python 5

FastAPI Docker로 배포하기

File Tree ┣ app ┃ ┣ common ┃ ┃ ┗ config.py ┃ ┣ database ┃ ┃ ┣ conn.py ┃ ┃ ┗ schema.py ┃ ┗ routes ┃ ┃ ┗ xxx_api.py ┣ docker_setting ┃ ┣ Dockerfile ┃ ┣ fastapi.yaml ┃ ┗ requirements.txt ┗ main.py main.py from fastapi import FastAPI # custom module from app.routes import xxxx_api from app.database.conn import db app = FastAPI() app.include_router(xxxx_api.router) db.init_app(app) if __name__ == '__..

Python/FastAPI 2024.03.15

[python] subprocess.run()과 Popen()의 timeout

[문제] subprocess.TimeoutExpired 에러가 발생한 경우, subprocess.run() 에서는 child process를 삭제할 수 없음 [해결] subprocess.Popen()으로 converting 했다. 방법 1. proc.kill()로 프로세스 종료 https://docs.python.org/3.9/library/subprocess.html The child process is not killed if the timeout expires, so in order to cleanup properly a well-behaved application should kill the child process and finish communication: proc = subprocess.P..

Python 2023.04.12

[python] UnicodeDecodeError: 'utf-8' codec can't decode byte 해결 방법

[현상] fd = subprocess.run(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, executable='/bin/bash') out = fd.stdout.decode('utf-8').strip() err = fd.stderr.decode('utf-8').strip() 위 코드 실행 중 다음과 같은 에러 발생 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xee in position 1583: invalid continuation byte [원인] The errors argument specifies the response when the ..

Python 2022.11.11
728x90