Remove unnecessary time.sleep(5) call in ramp-requests.py #659
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
In the ramp-requests.py file, there's no clear reason for using sleep(5) after executing the subprocess.run() method for an attack.
My guess is that when creating the process with run(), it was assumed to be non-blocking, and sleep(5) was given to match -duration 5s.
If this assumption is correct, the subprocess.run() method is blocking, and it won't execute the next command until the child process finishes, making the sleep unnecessary.
If there was an intention to add an arbitrary delay, there should be a specific comment or explanation. Otherwise, if someone assumes that subprocess.run() is non-blocking and adds time.sleep(5), it can cause confusion.
You can find more details about the blocking nature of subprocess in the following links:
Checklist