0으로 나눌 수있는 파이썬 코드가 있지만 파이썬 (3.2) 인터프리터에서 제대로 실행됩니다. 그러나 mod_wsgi를 사용하여 실행하려고하면 오류없이 중단되고 요청이 제공되지 않습니다.mod_wsgi가 응답하지 않습니다 RuntimeWarning : 0으로 나누기
인터프리터 경고 (출력이 올바른지) : pathwayAnalysis.py:30: RuntimeWarning: divide by zero encountered in double_scalars
아무도 올바른 방법은 mod_wsgi에 될 것이라고 사용하여이 작업을 실행하려면 무엇을 알고 있나요?
코드는 다음과 같습니다. 차이와 크기는 둘 다 길이가 2 인 numpy float 배열입니다. difference
에있는 float 중 하나는 0 (둘 다는 아닐 수도 있음) 일 수 있습니다. 이 올바르게 실행하게되지만 출력 이후 좋은 해결책이 아니다 전에 difference += 0.0001
를 추가하는 것은 정확하지 않다 : 다음을 수행
if abs(difference[0]/difference[1]) > (size[0]/size[1]):
ratio = abs(size[0]/difference[0])
else: ratio = abs(size[1]/difference[1])
for i in range(len(base)):
result.append(base[i] + difference[i] * ratio/2)
return array(result)
작동하지 않습니다
try:
cond = abs(difference[0]/difference[1]) > (size[0]/size[1])
except RuntimeWarning:
cond = True
# hangs before this point
if cond:
'''as above'''
일부 테스트 코드를 (둘 중 하나를 사용하여 difference
정의)의 :
def application(environ, start_response):
from numpy import array
size = array([10., 10.])
difference = array([115., 0.]) # hangs
difference = array([115., 10.]) # returns page with text 'Yes.'
if abs(difference[0]/difference[1]) > (size[0]/size[1]):
output = 'Yes.'
else:
output = 'No.'
status = '200 OK'
response_headers = [('Content-type', 'text/plain'),\
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
사용중인 mod_wsgi의 버전을 나타내거나 오류가있는 코드가 포함 된 완전한 자체 자체 WSGI hello world를 제공 할 수 있습니까? 그런 식으로 코드의 의도를 올바르게 복사했는지 여부를 쉽게 추측 할 수 있습니다. 먼저 http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide#WSGI_Application_Script_File에서 예제를 시작하고 코드를 추가하여 실패하게 만듭니다. 예제는 현재는 아니지만 Python 3과 호환되도록 만들어야합니다. –
mod_wsgi-3.3.0을 사용하고 있습니다. 나중에 hello world 예제로 업데이트 하겠지만, if (abs (difference [0])/(abs (difference [1]) + 0.001))> (size [0]/size [1]) :'이것은 방금 처리하지 못하는 지저분한 해결책으로 보인다. – kai
@GrahamDumpleton 안녕하세요 세계 예는 동일한 동작을 보여줍니다. 내가 말할 수있는 한 그것은 파이썬 3 호환입니까? – kai