请求崩溃时作为WSGI嵌入,但不作为独立时

2024-04-26 22:42:05 发布

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

import sys
import os
import logging

# need to add environment to apache's path for includes
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), ".")))
# likewise add cherrypy/other modules
sys.path.append(os.path.abspath("/Library/Python/2.7/site-packages/"))

import requests
response = requests.get('http://www.google.com').text

使用python2.7.6、requests 2.7.0和mamp3.0下的Apache,上述代码崩溃。快速浏览一下使用winpdb的代码似乎表明,实际上试图打开internet连接是破坏Python进程的原因。Apache日志不是很有用,只是说

[notice] child pid 18879 exit signal Segmentation fault (11)

虽然我的完整代码使用cherrypy3.8来提供框架的WSGI部分,但我觉得它与当前的问题无关。你知道吗

这是requests+apache的已知问题,还是其他问题?Python崩溃而没有任何评论,这让我很难想出一种方法来开始解决这个问题。你知道吗

编辑:使用pdb,我发现程序在URL库.py在python标准库中。你知道吗

proxy_settings = _get_proxy_settings()

其中,获取代理设置来自scproxy。你知道吗

我还是不知道怎么解决这个问题。你知道吗


Tags: topath代码importaddgetosapache