-1

I am making an api in quart which is based on aiohttp in python and its an asynchronous library and when i run the api locally everything runs fine but if i run it on docker it gives me errors on endpoints

api_1  |   File "asyncpg/protocol/protocol.pyx", line 301, in query
api_1  |   File "asyncpg/protocol/protocol.pyx", line 664, in asyncpg.protocol.protocol.BaseProtocol._check_state
api_1  | asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress

This is on an endpoint which works fine locally

Dockerfile

FROM python:3.8-slim

# left to be done after project structure
WORKDIR /app

ADD . /app

RUN pip install pipenv
RUN pipenv install --system --deploy
CMD python launch.py initdb
CMD sh /app/runfile.sh

runfile.sh

hypercorn launch:app -b 0.0.0.0:5000

Dockerfile after applying change that was suggested

FROM python:3.8-alpine

# left to be done after project structure
WORKDIR /app

ADD . /app

RUN apk add gcc python3-dev musl-dev

RUN pip install pipenv
RUN pipenv install --system --deploy
CMD python launch.py initdb
CMD sh /app/runfile.sh

1 Answers1

0

I have found a solution. The problem is lacking of connections in pool. so await connection with using acquire() like as mentioned above.

Akihito KIRISAKI
  • 1,243
  • 6
  • 12
  • [This comment](https://github.com/MagicStack/asyncpg/issues/258#issuecomment-650276156) says don't share connection pool in different worker. Why don't you try to run as single worker? Then, increase it. – Akihito KIRISAKI Dec 15 '20 at 09:45