Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

resolve pytest-httpserver hanging on stop after test cleanup

Nick Sweetingfc0af9e1e9de
diff --git a/pyproject.toml b/pyproject.toml
index b2621b1e2..04b29b0a1 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,7 +2,7 @@
name = "browser-use"
description = "Make websites accessible for AI agents"
authors = [{ name = "Gregor Zunic" }]
-version = "0.5.0"
+version = "0.5.1"
readme = "README.md"
requires-python = ">=3.11,<4.0"
classifiers = [
diff --git a/tests/ci/conftest.py b/tests/ci/conftest.py
index 5641c7f8e..426143ba5 100644
--- a/tests/ci/conftest.py
+++ b/tests/ci/conftest.py
@@ -5,6 +5,7 @@ Sets up environment variables to ensure tests never connect to production servic
"""
import os
+import socketserver
import tempfile
from unittest.mock import AsyncMock
@@ -12,6 +13,12 @@ import pytest
from dotenv import load_dotenv
from pytest_httpserver import HTTPServer
+# Fix for httpserver hanging on shutdown - prevent blocking on socket close
+# This prevents tests from hanging when shutting down HTTP servers
+socketserver.ThreadingMixIn.block_on_close = False
+# Also set daemon threads to prevent hanging
+socketserver.ThreadingMixIn.daemon_threads = True
+
from browser_use.agent.views import AgentOutput
from browser_use.controller.service import Controller
from browser_use.llm import BaseChatModel