作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
按照以下说明进行操作:https://docs.gitlab.com/ce/ci/services/redis.html我已经添加了
services:
- redis:latest
到我的 .gitlab-ci.yml
文件,并更改为 redis 连接调用:
redis.StrictRedis(host='redis', port=6379, db=0)
我得到的错误是:
/usr/local/lib/python2.7/site-packages/redis/client.py:772: in execute_command
connection = pool.get_connection(command_name, **options)
/usr/local/lib/python2.7/site-packages/redis/connection.py:994: in get_connection
connection.connect()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Connection<host=redis,port=6379,db=0>
def connect(self):
"Connects to the Redis server if not already connected"
if self._sock:
return
try:
sock = self._connect()
except socket.timeout:
raise TimeoutError("Timeout connecting to server")
except socket.error:
e = sys.exc_info()[1]
> raise ConnectionError(self._error_message(e))
E ConnectionError: Error -2 connecting to redis:6379. Name or service not known.
最佳答案
事实证明,这就像将服务声明放入每个任务一样简单,例如:
py27:
stage: run
image: python:2.7
script:
- mkdir -p build/coverage
- pip install -r requirements.txt
- pytest --color=no --verbose --ignore=almanac/migrations --cov=almanac --cov-config=.coveragerc tests
- cp .coverage build/coverage/py27.coverage
services: # <===== here ========
- redis:latest
artifacts:
paths:
- build/coverage/*.coverage
关于python - 如何在 gitlab 管道中从 Python 连接到 redis?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56756751/
我是一名优秀的程序员,十分优秀!