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

Option to Skip Monkey Patching with LOCUST_SKIP_MONKEY_PATCH #2765

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

andrewbaldwin44
Copy link
Collaborator

Proposal

  1. Add a condition to the __init__.py that will skip monkey patching when LOCUST_SKIP_MONKEY_PATCH is set
  2. Update use-as-lib to document disabling monkey patching

Tested

Tested using Locust as a lib with boto3

Fixes #2250

@cyberw
Copy link
Collaborator

cyberw commented Jun 21, 2024

Cool! Would it work if we also automatically skipped monkey patching if it has already been done, like this?

if not monkey.is_module_patched("thread"):
    monkey.patch_all()
else:
    print("Skipping monkey patching, because it had already been performed")

@andrewbaldwin44
Copy link
Collaborator Author

That was the first thing I tried, unfortunately it doesn't work. I went with this solution since I saw both yourself and Heyman suggested it in another thread

@cyberw cyberw merged commit 932f6c3 into locustio:master Jun 21, 2024
14 checks passed
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

Successfully merging this pull request may close these issues.

Mass monkeypatching leads to boto3 incompatibility and infinite recursion in pytest (when used as lib)
2 participants