Skip to content

Commit

Permalink
simplify distributor example
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberw committed Feb 13, 2024
1 parent d152c65 commit ec292ce
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions examples/distributor_ex.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@

@events.init.add_listener
def on_locust_init(environment, **_kwargs):
ssn_reader = None
product_reader = None
ssn_iterator = None
product_iterator = None
if not isinstance(environment.runner, WorkerRunner):
product_reader = CSVReader("products.csv")
csv = True
if csv:
ssn_reader = CSVDictReader("ssn.tsv", delimiter="\t")
else:
ssn_reader = MongoLRUReader({"foo": "bar"}, "last_login")
product_reader = CSVReader("products.csv")
distributors["customers"] = Distributor(environment, ssn_reader, "customers")
distributors["products"] = Distributor(environment, product_reader, "products")
product_iterator = CSVReader("products.csv")
ssn_iterator = CSVDictReader("ssn.tsv", delimiter="\t")
# other readers work equally well
# ssn_reader = MongoLRUReader({"foo": "bar"}, "last_login")
distributors["products"] = Distributor(environment, product_iterator, "products")
distributors["customers"] = Distributor(environment, ssn_iterator, "customers")


class MyUser(HttpUser):
Expand Down

0 comments on commit ec292ce

Please sign in to comment.