๋ฐ์ํ
httplib๋ก API URI ํธ์ถํ๋ ๊ณผ์ ์์ ์๋์ ๊ฐ์ ์๋ฌ๊ฐ ๋ฐ์ํ์ต๋๋ค.
API ํธ์ถ์ ๋ฐ๋ณตํ์ฌ ๊ณ์ ํธ์ถํ๋ ์ฝ๋์๋๋ฐ,
์ฒซ๋ฒ์งธ ํธ์ถ์ ์ ์์ ์ผ๋ก ํธ์ถ ๋์ง๋ง ๋๋ฒ์งธ ํธ์ถ๋ถํฐ ์๋ฌ๊ฐ ๋ฐ์ํ๋ค์
Traceback (most recent call last):
File "test.py", line 40, in
clusterInfo = getAppPendingCnt(conn)
File "yarnAppStatus.py", line 9, in getAppPendingCnt
r1 = conn.getresponse()
File "/usr/lib64/python2.7/httplib.py", line 1113, in getresponse
response.begin()
File "/usr/lib64/python2.7/httplib.py", line 444, in begin
version, status, reason = self._read_status()
File "/usr/lib64/python2.7/httplib.py", line 408, in _read_status
raise BadStatusLine(line)
httplib.BadStatusLine: ''
๐ซ ๋ฌธ์ ์ฝ๋
- ์์ธ: connection์ ๋์ง ์๊ณ ์ฌํธ์ถํด์ ๋ฐ์ํ ๋ฌธ์
- ์กฐ์น๋ฐฉ๋ฒ: connection close > retry connection > api call
conn = httplib.HTTPConnection('host','port')
while 1:
callApi(conn)
๐ก ์์ ์ฝ๋
while 1:
conn = httplib.HTTPConnection('host','port')
callApi(conn)
conn.close()