내 응용 프로그램에서 이상한 오류가 발생했습니다. Exception 클래스에 try-except를 두었 기 때문에 기계 라이브러리 때문에 생성되지 않습니다.파이썬 코드의 이상한 예외 - mechanize and beautifulsoup
게다가 browser.open()은 아무 문제없이 필요한 주소를 반환합니다. 또한이 예외는 10 번 중 1 번 발생하지 않습니다.
이def check_result(self, submission_id, question_code):
"""
returns the result of a problem submission.
:return: result codde
RA - right answer
WA - wrong answer
CE - Compilation error
RE - Runtime Error
"""
print "================================"
print "Response:"
try:
response = self._br.open(self.URL + '/status/' + question_code)
except Exception: # TODO get more specific exception for better stack trace
raise ExceptionSet.InternetConnectionFailedException
# print response.read()
response = BeautifulSoup(response.read(), 'html.parser')
tables = response.findChildren('table')
table = tables[0]
rows = table.findChildren(['tr', 'th'])
result = ''
flag = False
for row in rows:
cells = row.findChildren('td')
for cell in cells:
if cell.string == submission_id:
flag = True
result = cell.string
break
if flag:
break
print result
정확한 스택 추적은 다음과 같습니다 :
Exception mechanize._response.httperror_seek_wrapper:
<httperror_seek_wrapper (urllib2.HTTPError instance) at 0x7fd87195fbb0
whose wrapped object = <closeable_response at 0x7fd87490dc20 whose fp =
<response_seek_wrapper at 0x7fd87195c830 whose wrapped object =
<closeable_response at 0x7fd87195c2d8 whose fp = <socket._fileobject
object at 0x7fd8719706d0>>>>> in <bound method API.__del__ of
<CodeChef.API instance at 0x7fd8749249e0>> ignored
감사
나는 그것이 무엇인지 아무 생각이 ...
이
도와주세요이 코드입니다 당신!죄송합니다. 명백하고 직접적인 문제인 경우.
편집 : 분명히이 코드 조각에는 문제가 없습니다. 아직 해결하려고합니다. 당신이 정말로 도움이 될 어떤 단서를 줄 수 있다면.
코드에 대한 링크입니다 : 내가 바로 여기에 코드를 게시하는 경우는 언급하시기 바랍니다 https://github.com/ParadoxZero/CodechefAPI
.
감사합니다.
편집 2 :
오류의 원인을 찾을 수 있지만, 여전히 일어난 이유를 이해하지 않습니다. __ del __()에서 logout() 함수를 호출했습니다. __ del __()을 제거하면 오류가 해결되었습니다.
하지만 여전히 그게 무엇인지, 왜 일어 났는지 이해하지 못합니다.