Skip to content

Commit

Permalink
Merge pull request #200 from atlanticwave-sdx/199.bapm-cpu-usage
Browse files Browse the repository at this point in the history
Avoid busy wait in bapm_server
  • Loading branch information
sajith authored Jan 22, 2024
2 parents 6dc80e9 + 5958b93 commit b3c3040
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions bapm_server/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ def start_consumer(thread_queue, es):
t1.start()

while True:
if not thread_queue.empty():
data = thread_queue.get()
if is_json(data):
resp = es.index(index="measurement-index", id=MSG_ID, document=data)
print(resp["result"])
MSG_ID += 1
else:
logger.info("Received non-JSON data. Not saving to ElasticSearch.")
data = thread_queue.get()
if is_json(data):
resp = es.index(index="measurement-index", id=MSG_ID, document=data)
print(resp["result"])
MSG_ID += 1
else:
logger.info("Received non-JSON data. Not saving to ElasticSearch.")


def main():
Expand Down

0 comments on commit b3c3040

Please sign in to comment.