Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looking for a different flavor of on_start() behavior #714

Closed
markcampanelli-wf opened this issue Dec 19, 2017 · 3 comments
Closed

Looking for a different flavor of on_start() behavior #714

markcampanelli-wf opened this issue Dec 19, 2017 · 3 comments

Comments

@markcampanelli-wf
Copy link

Description of issue / feature request

My task workflow requires something like the on_start() in a super-TaskSet, but the requirement is that the on_start() function execute every time a sub-TaskSet is interrupted and returns control to the super-TaskSet. From what I can tell, the on_start() is only ever called once.

The use case is opening a document in the super-TaskSet and then, in the sub-TaskSet, manipulating and eventually closing/leaving the document (via an interrupt) and returning to the super-TaskSet where the document must then be re-opened before returning to the sub-TaskSet.

Perhaps I am missing an existing pattern for achieving this workflow?

Expected behavior

N/A

Actual behavior

A/A

Environment settings (for bug reports)

  • OS: Mac
  • Python version: 3.6.3
  • Locust version: 1.8.1

Steps to reproduce (for bug reports)

N/A

@heyman
Copy link
Member

heyman commented Dec 20, 2017

Could you maybe do it in TaskSet.execute_next_task() (https://github.com/locustio/locust/blob/master/locust/core.py#L295-L297) in the super-TaskSet?

Something like:

class SuperTaskSet(TaskSet):
    def execute_next_task(self):
        # insert code to be executed before every task here
        
        super(SuperTaskSet, self).execute_next_task()

@markcampanelli-wf
Copy link
Author

Thanks @heyman. I'll give this a try today and report back here.

@markcampanelli-wf
Copy link
Author

@heyman This solution works and seems reasonable. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants