forked from SvenskaSpel/locust-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug_ex.py
30 lines (24 loc) · 1014 Bytes
/
debug_ex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Example of how to use VS Code debugger with Locust.
# Make sure you set "gevent": true in your launch.json
# In recent versions of VSCode you might get the following warning. I dont know why, but it seems safe to ignore.
#
# PYDEV DEBUGGER WARNING:
# sys.settrace() should not be used when the debugger is being used.
# This may cause the debugger to stop working correctly.
# If this is needed, please check:
# http://pydev.blogspot.com/2007/06/why-cant-pydev-debugger-work-with.html
# to see how to restore the debug tracing back correctly.
#
# (if you know why this happens, please let me know :)
from locust import task, HttpUser
from locust.exception import StopUser
from locust_plugins import run_single_user
class MyUser(HttpUser):
@task
def t(self):
self.client.get("/")
raise StopUser()
# when executed as a script, run a single locust in a way suitable for the vs code debugger
if __name__ == "__main__":
MyUser.host = "http://example.edu"
run_single_user(MyUser)