Skip to content

Commit

Permalink
Catch the exception when deleting downloaded locustfiles if the file …
Browse files Browse the repository at this point in the history
…has already been deleted.
  • Loading branch information
cyberw committed Feb 11, 2024
1 parent db9f077 commit 78d57ed
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions locust/argument_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ def download_locustfile_from_url(url: str) -> str:
locustfile.write(response.text)

def exit_handler():
os.remove(locustfile.name)
try:
os.remove(locustfile.name)
except FileNotFoundError:
pass # this is normal when multiple workers are running on the same machine

atexit.register(exit_handler)
return locustfile.name
Expand Down Expand Up @@ -250,7 +253,10 @@ def wait_for_reply():
locustfile.write(msg.data["contents"])

def exit_handler():
os.remove(locustfile.name)
try:
os.remove(locustfile.name)
except FileNotFoundError:
pass # this is normal when multiple workers are running on the same machine

atexit.register(exit_handler)

Expand Down

0 comments on commit 78d57ed

Please sign in to comment.