Search code examples
pythonpipgrpcpypi

Pypi / pip blocks while downloading grpcio-reflection


Installing grpcio-reflection with pip takes a really long time.

It is strange because the pip package is only 8KB in PyPI but downloading takes more than a minute while other packages that are in the megabytes are downloaded really fast.

UPDATE: It was not downloading, there is a lot of compilation going on. It seems to be that the feature is still in alpha so the package is not precompiled like standard grpcio

UPDATE2: Repro steps

I have just opened an issue here: https://github.com/grpc/grpc/issues/12992 and I am copying the repro steps here for completion.

It seems that grpci-reflection package installation freezes depending on other packages in the same command line

This can be easily reproduced by these two docker different containers:

Dockerfile.fast - Container creation time ~1m 23s

#Download base ubuntu image
FROM ubuntu:16.04
RUN apt-get update && \
    apt-get -y install ca-certificates curl

# Prepare pip 
RUN apt-get -y install python-pip
RUN pip install -U pip
RUN pip install grpcio grpcio-tools
RUN pip install grpcio-reflection         # Two lines is FAST

Dockerfile.slow - Container creation time 5m 20s

#Download base ubuntu image
FROM ubuntu:16.04
RUN apt-get update && \
    apt-get -y install ca-certificates curl

# Prepare pip
RUN apt-get -y install python-pip
RUN pip install -U pip
RUN pip install grpcio grpcio-tools grpcio-reflection  # Single line is SLOW

Timing containers build time:

time docker build --rm --no-cache -f Dockerfile.fast -t repro_reflbug_fast:latest .
......
real    1m22.295s
user    0m0.060s
sys     0m0.040s

time docker build --rm --no-cache -f Dockerfile.slow -t repro_reflbug_slow:latest .
.....
real    6m28.290s
user    0m0.052s
sys     0m0.052s
.....

I didn't have time yet to investigate but the second case blocks for a long time while the first one doesnt.


Solution

  • It turns out that this issue was accepted as valid in the corresponding GitHub repo. It is now being discussed here:

    https://github.com/grpc/grpc/issues/12992