Skip to content

Commit 95d3cbf

Browse files
authored
fix(mysql): handle InterfaceError during health check (#105)
MySQL can throw `InterfaceError` (not just `OperationalError`) with "Lost connection" when the container isn't ready during startup
1 parent 8e8dc2c commit 95d3cbf

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ license = "MIT"
1212
name = "pytest-databases"
1313
readme = "README.md"
1414
requires-python = ">=3.9"
15-
version = "0.15.0"
15+
version = "0.15.1"
1616
#
1717
authors = [{ name = "Cody Fincher", email = "cody@litestar.dev" }]
1818
keywords = [
@@ -124,7 +124,7 @@ dev = [
124124
allow_dirty = true
125125
commit = false
126126
commit_args = "--no-verify"
127-
current_version = "0.15.0"
127+
current_version = "0.15.1"
128128
ignore_missing_files = false
129129
ignore_missing_version = false
130130
message = "chore(release): bump to `v{new_version}`"

src/pytest_databases/docker/mysql.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ def check(_service: ServiceContainer) -> bool:
5757
database=database,
5858
password=password,
5959
)
60-
except mysql.connector.errors.OperationalError as exc:
61-
if "Lost connection" in exc.msg: # type: ignore
60+
except (mysql.connector.errors.OperationalError, mysql.connector.errors.InterfaceError) as exc:
61+
msg = getattr(exc, "msg", str(exc))
62+
if "Lost connection" in msg:
6263
return False
6364
raise
6465

uv.lock

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)