Skip to content
Permalink
Browse files

fix(service): minor fix on the dump_interval

  • Loading branch information...
hanxiao committed Oct 10, 2019
1 parent cd77a57 commit 73dae6bdea612d375a103627e725c5ade5865011
Showing with 6 additions and 8 deletions.
  1. +6 −2 gnes/service/base.py
  2. +0 −6 tests/test_service_mgr.py
@@ -336,12 +336,14 @@ def run(self):
except Exception as ex:
self.logger.error(ex, exc_info=True)

def dump(self):
def dump(self, respect_dump_interval: bool = True):
if (not self.args.read_only
and self.args.dump_interval > 0
and self._model
and self.is_model_changed.is_set()
and (time.perf_counter() - self.last_dump_time) > self.args.dump_interval):
and (respect_dump_interval
and (time.perf_counter() - self.last_dump_time) > self.args.dump_interval)
or not respect_dump_interval):
self.is_model_changed.clear()
self.logger.info('dumping changes to the model, %3.0fs since last the dump'
% (time.perf_counter() - self.last_dump_time))
@@ -459,6 +461,8 @@ def _run(self, ctx):
in_sock.close()
out_sock.close()
ctrl_sock.close()
# do not check dump_interval constraint as the last dump before close
self.dump(respect_dump_interval=False)
self.logger.critical('terminated')

def post_init(self):
@@ -97,8 +97,6 @@ def test_external_module(self):

with ServiceManager(RouterService, args):
pass
self.assertTrue(os.path.exists('foo_contrib_encoder.bin'))
os.remove('foo_contrib_encoder.bin')

def test_override_module(self):
args = set_indexer_parser().parse_args([
@@ -108,8 +106,6 @@ def test_override_module(self):

with ServiceManager(IndexerService, args):
pass
self.assertTrue(os.path.exists('foo_contrib_encoder.bin'))
os.remove('foo_contrib_encoder.bin')

def test_override_twice_module(self):
args = set_indexer_parser().parse_args([
@@ -120,8 +116,6 @@ def test_override_twice_module(self):

with ServiceManager(IndexerService, args):
pass
self.assertTrue(os.path.exists('foo_contrib_encoder.bin'))
os.remove('foo_contrib_encoder.bin')

def test_grpc_with_pub(self):
self._test_grpc_multiple_pub('thread', 1)

0 comments on commit 73dae6b

Please sign in to comment.
You can’t perform that action at this time.