From 1faf2f9aff468edc7c18cd330c27ebc5db3089b1 Mon Sep 17 00:00:00 2001 From: tdadela Date: Mon, 22 Jul 2024 18:41:12 +0200 Subject: [PATCH] fix: worker disconnections when urllib3>=1.26.16 #2812 --- locust/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/locust/__init__.py b/locust/__init__.py index 57f3f91cc8..b5c69c81e1 100644 --- a/locust/__init__.py +++ b/locust/__init__.py @@ -10,11 +10,17 @@ # dont show a massive callstack if trio is not installed os._exit(1) -from gevent import monkey - if not os.getenv("LOCUST_SKIP_MONKEY_PATCH", None): + from gevent import monkey, queue + monkey.patch_all() + if not os.getenv("LOCUST_SKIP_URLLIB3_PATCH", None): + import urllib3 + + urllib3.connectionpool.ConnectionPool.QueueCls = queue.LifoQueue + # https://github.com/locustio/locust/issues/2812 + from ._version import version as __version__ from .contrib.fasthttp import FastHttpUser from .debug import run_single_user