Call a method with arguments through thread in Python

tech kamar
Sep 5, 2024
import threading

def run_request(req_number):
print(f"Running Request Number from client: {req_number}")
resp = requests.get("http://0.0.0.0:8080/test/"+str(req_number))
print(resp.json())

def main():
max_req_count = 100
for rq_count in range(0,max_req_count):
run_request_thread = threading.Thread(target=run_request, args=(rq_count,))
run_request_thread.start()


if __name__ == "__main__":
main()

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response