As I said In slack, I know there is an easy workaround of defining only one task in the TaskSet and defining all the behavior there. The problem with the workaround is that it is a bit hacky, since you have to do self.wait() whenever it's needed instead of letting the framework handle it.
If accepted this pr will
Introduce a new class: TaskSequence which accepts a new decorator @seq_task(int) to define the order of the tasks.
For example:
classBrowseDocumentationSequence(TaskSquence):
defon_start(self):
self.urls_on_current_page=self.toc_urls# assume all users arrive at the index page@seq_task(1)defindex_page(self):
r=self.client.get("/")
pq=PyQuery(r.content)
link_elements=pq(".toctree-wrapper a.internal")
self.toc_urls= [
l.attrib["href"] forlinlink_elements
]
@seq_task(2)@task(50)defload_page(self, url=None):
url=random.choice(self.toc_urls)
r=self.client.get(url)
pq=PyQuery(r.content)
link_elements=pq("a.internal")
self.urls_on_current_page= [
l.attrib["href"] forlinlink_elements
]
@seq_task(3)@task(30)defload_sub_page(self):
url=random.choice(self.urls_on_current_page)
r=self.client.get(url)
In the example above, index_page/1 will be executed first, then load_page/1 fifty times, and then load_sub_page/1 thirty times.
@seq_task(int) doesn't have a default parameter because I found that if I set the same order value to every task, the final order ends up being kind of random.
Well, finally I decided not to change the quick start because it's supposed to be short. Instead I've updated the api.rst and writing-locustfile.rst files. If there is anything else needed, just tell me :)
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.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
This pr is related to this issue.
As I said In slack, I know there is an easy workaround of defining only one task in the TaskSet and defining all the behavior there. The problem with the workaround is that it is a bit hacky, since you have to do
self.wait()
whenever it's needed instead of letting the framework handle it.If accepted this pr will
Introduce a new class:
TaskSequence
which accepts a new decorator @seq_task(int) to define the order of the tasks.For example:
In the example above, index_page/1 will be executed first, then load_page/1 fifty times, and then load_sub_page/1 thirty times.
@seq_task(int)
doesn't have a default parameter because I found that if I set the same order value to every task, the final order ends up being kind of random.