Skip to content

Commit

Permalink
ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob Mellberg committed Mar 20, 2024
1 parent 4b4429e commit 3ab54c3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion kea_exporter/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
from . import __project__, __version__


class Timer():
class Timer:
def __init__(self):
self.reset()

def reset(self):
self.start_time = time.time()

def time_elapsed(self):
now_time = time.time()
return now_time - self.start_time


@click.command()
@click.option(
"-m",
Expand Down Expand Up @@ -85,12 +88,14 @@ def cli(mode, port, address, interval, **kwargs):

def local_wsgi_app(registry):
func = make_wsgi_app(registry, False)

def app(environ, start_response):
if t.time_elapsed() >= interval:
exporter.update()
t.reset()
output_array = func(environ, start_response)
return output_array

return app

httpd.set_app(local_wsgi_app(REGISTRY))
Expand All @@ -100,5 +105,6 @@ def app(environ, start_response):
while True:
time.sleep(1)


if __name__ == "__main__":
cli()

0 comments on commit 3ab54c3

Please sign in to comment.