我正在macOS机器支持的Docker容器中运行服务器,我需要从中发送多个图像以供Google Cloud Vision API处理。

对我而言,当务之急是能够最大程度地减少上载和处理图像所花费的时间。

我首先将对GCV的调用包装在Queue.QueueThreading.Thread中,但这偶尔会崩溃我的代码(没有被python Exception捕获),因此:

E1121 14:15:10.902211037   25448 sync_posix.c:38]            assertion failed: pthread_mutex_destroy(mu) == 0

根据几个github线程的说法,这是gRPC启发的(或httplib?)bug/功能,但是我找不到简单的解决方法的步骤-参见例如https://github.com/grpc/grpc/issues/11184https://github.com/grpc/grpc/issues/10909

鉴于这似乎是一个普遍遇到的问题,没有明确的解决方案,那么减轻它的最佳方法是什么?

是否像对GCV使用单个批处理调用一样简单(但是总体速度如何?)?没有其他方法可以安全地对调用进行线程处理吗?

更新:

由于担心损坏,我开始将gRPC回滚到v1.2.x la

https://github.com/grpc/grpc/issues/10909#issuecomment-302581954

除非我必须在Docker容器中的/usr/local/lib中添加LD_LIBRARY_PATH才能选择libprotobuf.so.12

我没有对其他任何python包进行任何更改。

然后我做了:
pip install grpcio==1.2.1

显然这很昂贵,但是崩溃率是以前的1/3个调用的
现在:如何确定性地确定此问题已解决?

最佳答案

这是我使用过的Dockerfile的相关部分(基于https://github.com/grpc/grpc/issues/10909#issuecomment-302581954)

# gRPC fix (rollback to v1.2.x to mitigate mutex crashing bug)
RUN apt-get install -y build-essential autoconf libtool
RUN apt-get install -y libgflags-dev libgtest-dev
RUN apt-get install -y clang libc++-dev
RUN apt-get install -y sudo unzip locate
RUN mkdir -p /app/src

WORKDIR /app/src
RUN git clone --branch v1.2.x https://github.com/grpc/grpc

WORKDIR /app/src/grpc
RUN git submodule foreach git clean -xfd
RUN git submodule update --init

WORKDIR /app/src/grpc/third_party/protobuf
RUN ./autogen.sh
RUN ./configure
RUN make -j2
RUN sudo make install

WORKDIR /app/src/grpc
RUN sudo make install
ENV LD_LIBRARY_PATH=${LD_LIBRARY}:/usr/local/lib
RUN pip install --trusted-host pypi.python.org grpcio==1.2.1
RUN pip install --trusted-host pypi.python.org google-cloud-vision

我将开放几天,以查看是否有人回应。

10-07 13:38
查看更多