Closed sha1n closed 8 months ago
I'm seeing unclosed socket warnings too, but seems like mine were caused by connections to docker. Here's the PR to fix it: https://github.com/testcontainers/testcontainers-python/pull/380
Hey @rstcruzo and @sha1n thanks for the reports and PRs! I've noted your PRs, will schedule to integrate them after #408 has been carried out to ease some fixes
Describe the bug
DbContainer
instances may trigger a warning regarding unclosed socket. This is caused by the fact thatDbContainer._connect
creates ansqlalchemy
engine and leaves it hanging after its done. I managed to reproduce it many time on an M1 macbook pro and fix it by changing the code to dispose the engine right before_connect
returns.Here is what the warning looks like:
To Reproduce
I run
pytest
with the following ini options and it fails every few runsRuntime environment
$ uname -a Darwin Shais-MBP.lan 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64
Get the python version.
$ python --version
$ docker info
$ poetry show