daemon: properly check for HTTP status codes
This commit is contained in:
parent
131601a7b2
commit
65f927122b
@ -70,10 +70,13 @@ class Daemon(util.LoggedClass):
|
|||||||
async with self.workqueue_semaphore:
|
async with self.workqueue_semaphore:
|
||||||
url = self.urls[self.url_index]
|
url = self.urls[self.url_index]
|
||||||
async with aiohttp.post(url, data=data) as resp:
|
async with aiohttp.post(url, data=data) as resp:
|
||||||
result = processor(await resp.json())
|
if resp.status == 200:
|
||||||
if self.prior_msg:
|
if self.prior_msg:
|
||||||
self.logger.info('connection restored')
|
self.logger.info('connection restored')
|
||||||
return result
|
result = processor(await resp.json())
|
||||||
|
return result
|
||||||
|
log_error('HTTP error code {:d}: {}'
|
||||||
|
.format(resp.status, resp.reason))
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
log_error('timeout error.', skip_once=True)
|
log_error('timeout error.', skip_once=True)
|
||||||
except aiohttp.ClientHttpProcessingError:
|
except aiohttp.ClientHttpProcessingError:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user