Skip to content

Commit

Permalink
use tqdm with publish message
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonray authored Dec 20, 2023
2 parents 824391b + a50fb0e commit 5d60262
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
24 changes: 24 additions & 0 deletions beanstalk-stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys
from loguru import logger
from pulpo_messaging.kessel import Message
from pulpo_messaging.kessel import Pulpo
from pulpo_messaging.kessel import PulpoConfig
from statman import Statman
import random
import argparse
import time
from tqdm import tqdm

parser = argparse.ArgumentParser(
prog='publish_sample_messages',
description='Published a set of test messages to kessel')

parser.add_argument('--config', type=str, help='path to config file')
args = parser.parse_args()

config = PulpoConfig().fromJsonFile(args.config).fromArgumentParser(args)
pulpo = Pulpo(config)
pulpo.initialize_queue_adapter()


Statman.report(log_method=logger.info)
3 changes: 2 additions & 1 deletion publish_sample_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import random
import argparse
import time
from tqdm import tqdm

parser = argparse.ArgumentParser(
prog='publish_sample_messages',
Expand Down Expand Up @@ -55,7 +56,7 @@ def create_random_message(payload: str):

def publish():
Statman.stopwatch(name='publish-sample-messages.timing', autostart=True)
for i in range(0, args.number_of_messages):
for i in tqdm(range(0, args.number_of_messages)):
m = create_random_message(payload=f'HellO WorlD {i}')
kessel.publish(m)
Statman.gauge(name='publish-sample-messages.published-messages').increment()
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ statman == 1.4.5
pulpo-config == 2.0.1
art == 6.1
greenstalk==2.0.2
loguru==0.7.0
tqdm==4.66.0
loguru==0.7.0

0 comments on commit 5d60262

Please sign in to comment.