在双python环境中,flask web服务器未在travisci中启动

2024-06-10 19:24:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我想融入我的项目。我的项目涉及Python中的flaskweb服务器和postgresql数据库。我的所有测试都使用在调试模式下运行的web服务器。我正试着把这个设置在崔维斯·西身上,有点麻烦。在

我正在Python2.7和3.4下构建和测试,问题是我的web服务器在3.4构建期间似乎没有启动。2.7版本首先启动,运行良好,我的所有测试都通过了,但是web服务器在3.4版本中无法启动。当我单独运行每个构建时,2.7和3.4版本都运行良好,所有测试都通过了。每个构建的web服务器之间是否存在冲突?这是我的特拉维斯·伊梅尔文件。在

language: python

sudo: false

python:
- '2.7'
- '3.4'

os:
- linux

services:
- postgresql
- memcached

addons:
  postgresql: '9.4'
  apt:
    packages:
      xvfb
      nano

branches:
- master

before_install:
- wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O ~/miniconda.sh
- bash ~/miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- conda update --yes conda

install:
- conda create --yes -n test_env python=$TRAVIS_PYTHON_VERSION pip numpy scipy matplotlib ipython --quiet
- source activate test_env
- pip install -r requirements.txt --quiet
- pip install psycopg2 --quiet
- pip install blinker --quiet
- pip install nose --quiet
- pip install coverage --quiet
- pip install pytest --quiet
- pip install pytest-cov --quiet
- pip install pytest-sugar --quiet
- python setup.py install

before_script:
- export MANGA_LOCALHOST=1
- export PYTHONPATH=$PYTHONPATH:$TRAVIS_BUILD_DIR/python
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3
- sh $TRAVIS_BUILD_DIR/bin/setup_travis
# make a local port based on python version, e.g. 5027 or 5034
- export LOCAL_MARVIN_PORT=50${TRAVIS_PYTHON_VERSION/.}
# start the local web server on port 50XX
- $TRAVIS_BUILD_DIR/bin/run_marvin -l -d -p $LOCAL_MARVIN_PORT > /dev/null &
- sleep 10
# list the processes running
- lsof -Pnl +M -i4
# test the web server is running
- curl http://localhost:$LOCAL_MARVIN_PORT/marvin2/api/general/getroutemap/

script:
- py.test python/marvin/tests -v --cov python/marvin --cov-report html

after_success:
- coveralls

最初本地web服务器运行在端口5000上,我认为这是可以的,因为每个python构建都应该是独立的。当时它不起作用,认为它可能与端口有关,所以我让每个web服务器在一个唯一的端口上运行,但这并没有解决问题。我正在打印各种各样的支票

在2.7版本中,web服务器运行在5027上,mycurl生成输出。在

^{pr2}$

它继续运行所有的测试。但是,我的3.4版本似乎无法在端口5034上启动web服务器,原因不明。港口的设置确实不同。在

$ lsof -Pnl +M -i4
COMMAND  PID     USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
Xvfb    3532     1000    1u  IPv4 34279725      0t0  TCP *:6099 (LISTEN)

$ curl http://localhost:$LOCAL_MARVIN_PORT/marvin2/api/general/getroutemap/
curl: (7) couldn't connect to host
The command "curl http://localhost:$LOCAL_MARVIN_PORT/marvin2/api/general/getroutemap/" failed and exited with 7 during .

同样,当我单独运行每个构建(2.7和3.4构建都成功)时,运行所有测试并通过。这是否与我如何将标准从web服务器转储到/dev/null有关?我应该在那里做些不同的事情吗?每一个构建不是完全独立的吗?在

更新:我只是在没有/dev/null的情况下尝试了一下,得到了相同的结果。这次,Python3.4领先于2.7版本,3.4版本成功地启动了web服务器并运行了测试。2.7版本无法启动web服务器,因此被另一个版本阻止。在


Tags: installpiptest版本服务器traviswebhttp