【发布时间】:2016-02-04 04:40:54
【问题描述】:
我正在尝试在我的测试框架中让网络服务器作为独立进程运行:
from subprocess import Popen, PIPE, STDOUT
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
server_cmd = "bundle exec thin start -p 3001 --ssl" # rails comamnd
# intend to start the server as a standalone process
webserver = Popen(server_cmd, shell=True, stdin=PIPE, stdout=PIPE,
stderr=PIPE, close_fds=True)
服务器运行良好,然后我执行一些Selenium 任务。第一次,这些任务执行得很好:
curl -v https://localhost:3001 -k
* Rebuilt URL to: https://localhost:3001/
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3001 (#0)
* TLS 1.0 connection using TLS_RSA_WITH_AES_256_CBC_SHA
* Server certificate: openca.steamheat.net
> GET / HTTP/1.1
> Host: localhost:3001
> User-Agent: curl/7.43.0
> Accept: */*
但是一旦任务重复,网络服务器就会停止运行:
curl -v https://localhost:3001 -k -L
* Rebuilt URL to: https://localhost:3001/
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3001 (#0)
* Closing connection 0
当我在shell 终端中执行相同的命令时,两个任务都按预期完成。
我想知道是否与stdout 的输出量有关,因为Rails 服务器向终端输出大量信息。
我该如何解决?网络服务器停止运行的原因是什么?
【问题讨论】:
标签: python multithreading process operating-system