Skip to content

Commit

Permalink
feat(server) use about_time to show timing and throughput stats
Browse files Browse the repository at this point in the history
  • Loading branch information
rsalmei committed Aug 27, 2018
1 parent d48cd30 commit 61a7273
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions clearly/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import operator
import re

from about_time import about_time
from celery.events.state import Task, Worker

from .event_core.event_listener import EventListener
Expand Down Expand Up @@ -117,7 +118,12 @@ def scondition(task):
self.listener.memory.tasks_by_time(limit=limit or None,
reverse=reverse)
if pcondition(task) and scondition(task))
for task in found_tasks:

def callback(t):
logger.debug('%s iterated %d tasks in %s (%s)', self.filter_tasks.__name__,
t.count, t.duration_human, t.throughput_human)

for task in about_time(callback, found_tasks):
yield ClearlyServer._event_to_pb(task)[1]

def filter_workers(self, request, context):
Expand All @@ -134,7 +140,12 @@ def hcondition(worker):
sorted(self.listener.memory.workers.values(),
key=WORKER_HOSTNAME_OP)
if hcondition(worker))
for worker in found_workers:

def callback(t):
logger.debug('%s iterated %d workers in %s (%s)', self.filter_workers.__name__,
t.count, t.duration_human, t.throughput_human)

for worker in about_time(callback, found_workers):
yield ClearlyServer._event_to_pb(worker)[1]

def find_task(self, request, context):
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'grpcio',
'protobuf',
'click',
'about-time',
]
if sys.version_info[0] == 2:
install_requires.append('futures')
Expand Down

0 comments on commit 61a7273

Please sign in to comment.