Skip to content

Commit

Permalink
Merge pull request #5 from ktarasz/patch-1
Browse files Browse the repository at this point in the history
Added extra loggers
  • Loading branch information
dimka2014 authored Jan 14, 2019
2 parents 62a2a83 + 910d6c0 commit 459b731
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion openprocurement_client/resources/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,13 @@ def get_resource_items(self):
LOGGER.info('Stop check backward worker')
check_down_worker = False
else:
if not self.backward_worker.successful():
LOGGER.warning('Exception from forward_worker: {}'.format(repr(self.backward_worker.exception)))
self.restart_sync()
check_down_worker = True
if self.forward_worker.ready():
if not self.forward_worker.successful():
LOGGER.warning('Exception from forward_worker: {}'.format(repr(self.forward_worker.exception)))
self.restart_sync()
check_down_worker = True
while not self.queue.empty():
Expand Down Expand Up @@ -185,9 +189,13 @@ def feeder(self):
LOGGER.info('Stop check backward worker')
check_down_worker = False
else:
if not self.backward_worker.successful():
LOGGER.warning('Exception from forward_worker: {}'.format(repr(self.backward_worker.exception)))
self.restart_sync()
check_down_worker = True
if self.forward_worker.ready():
if not self.forward_worker.successful():
LOGGER.warning('Exception from forward_worker: {}'.format(repr(self.forward_worker.exception)))
self.restart_sync()
check_down_worker = True
LOGGER.debug('Feeder queue size {} items'.format(self.queue.qsize()),
Expand All @@ -204,6 +212,9 @@ def retriever_backward(self):
LOGGER.debug('Backward response length {} items'.format(len(response.data)),
extra={'BACKWARD_RESPONSE_LENGTH': len(response.data)})
if self.cookies != self.backward_client.session.cookies:
LOGGER.info('Backward client Cookies mismatch: {}, {}'.format(
repr(self.cookies), repr(self.backward_client.session.cookies))
)
raise Exception('LB Server mismatch')
while response.data:
LOGGER.debug('Backward: Start process data.')
Expand All @@ -215,6 +226,9 @@ def retriever_backward(self):
LOGGER.debug('Backward response length {} items'.format(len(response.data)),
extra={'BACKWARD_RESPONSE_LENGTH': len(response.data)})
if self.cookies != self.backward_client.session.cookies:
LOGGER.info('Backward client Cookies mismatch: {}, {}'.format(
repr(self.cookies), repr(self.backward_client.session.cookies))
)
raise Exception('LB Server mismatch')
LOGGER.info('Backward: pause between requests {} sec.'.format(
self.retrievers_params.get('down_requests_sleep', 5)))
Expand All @@ -228,6 +242,9 @@ def retriever_forward(self):
LOGGER.debug('Forward response length {} items'.format(len(response.data)),
extra={'FORWARD_RESPONSE_LENGTH': len(response.data)})
if self.cookies != self.forward_client.session.cookies:
LOGGER.info('Forward client Cookies mismatch: {}, {}'.format(
repr(self.cookies), repr(self.forward_client.session.cookies))
)
raise Exception('LB Server mismatch')
while 1:
self.forward_heartbeat = time()
Expand All @@ -240,6 +257,9 @@ def retriever_forward(self):
LOGGER.debug('Forward response length {} items'.format(len(response.data)),
extra={'FORWARD_RESPONSE_LENGTH': len(response.data)})
if self.cookies != self.forward_client.session.cookies:
LOGGER.info('Forward client Cookies mismatch: {}, {}'.format(
repr(self.cookies), repr(self.forward_client.session.cookies))
)
raise Exception('LB Server mismatch')
if len(response.data) != 0:
LOGGER.info(
Expand All @@ -264,6 +284,9 @@ def retriever_forward(self):
if self.retrievers_params['up_wait_sleep'] < 30:
self.retrievers_params['up_wait_sleep'] += 1
if self.cookies != self.forward_client.session.cookies:
LOGGER.info('Forward client Cookies mismatch: {}, {}'.format(
repr(self.cookies), repr(self.forward_client.session.cookies))
)
raise Exception('LB Server mismatch')

return 1
Expand Down Expand Up @@ -309,4 +332,4 @@ def get_tenders(host=DEFAULT_API_HOST, version=DEFAULT_API_VERSION,

if __name__ == '__main__':
for tender_item in get_tenders():
print('Tender {0[id]}'.format(tender_item))
print('Tender {0[id]}'.format(tender_item))

0 comments on commit 459b731

Please sign in to comment.