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

fix: Close docker client when stopping the docker container #380

Merged
merged 2 commits into from
Mar 9, 2024

Conversation

rstcruzo
Copy link
Contributor

@rstcruzo rstcruzo commented Aug 17, 2023

Fixes the following warning

sys:1: ResourceWarning: unclosed <socket.socket fd=7, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0, raddr=/Users/rodrigo/.docker/run/docker.sock>

Related to #379

@alexanderankin
Copy link
Member

can you add a reproducer? i cannot replicate with:

PostgresContainer.py
from typing import Any

from sqlalchemy import create_engine, Engine, Connection, CursorResult, text
from testcontainers.postgres import PostgresContainer

p = PostgresContainer("postgres:14-alpine")


def main():
    p.start()
    engine: Engine = create_engine(p.get_connection_url())
    with engine.connect() as conn:
        conn: Connection = conn
        conn.execute(text("create table if not exists hero(name varchar(500) unique)"))
        conn.execute(text("insert into hero(name) values ('alice')"))
        conn.execute(text("insert into hero(name) values ('bob')"))
        with conn.execute(text('select * from hero')) as execute:
            execute: CursorResult[Any] = execute
            print(execute.fetchall())


if __name__ == '__main__':
    main()

@alexanderankin alexanderankin changed the title Close docker client when stopping the docker container fix: Close docker client when stopping the docker container Mar 9, 2024
@alexanderankin alexanderankin merged commit efb1683 into testcontainers:main Mar 9, 2024
7 of 8 checks passed
bearrito pushed a commit to bearrito/testcontainers-python that referenced this pull request Mar 9, 2024
…ainers#380)

Fixes the following warning

```
sys:1: ResourceWarning: unclosed <socket.socket fd=7, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0, raddr=/Users/rodrigo/.docker/run/docker.sock>
```
 Related to testcontainers#379

Co-authored-by: David Ankin <[email protected]>
alexanderankin added a commit that referenced this pull request Mar 11, 2024
🤖 I have created a release *beep* *boop*
---


##
[4.0.1](testcontainers-v4.0.0...testcontainers-v4.0.1)
(2024-03-11)


### Features

* **postgres:** Remove SqlAlchemy dependency from postgres container
([#445](#445))
([f30eb1d](f30eb1d))


### Bug Fixes

* **clickhouse:** clickhouse waiting
([#428](#428))
([902a5a3](902a5a3))
* Close docker client when stopping the docker container
([#380](#380))
([efb1683](efb1683))
* failing tests for elasticsearch on machines with ARM CPU
([#454](#454))
([701b23a](701b23a))
* **mongodb:** waiting for container to start (it was not waiting at all
before?)
([#461](#461))
([2c4f171](2c4f171))
* unclosed socket warning in db containers
([#378](#378))
([cd90aa7](cd90aa7))
* Update the copyright header for readthedocs
([#341](#341))
([5bef18a](5bef18a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Ankin <[email protected]>
alexanderankin added a commit that referenced this pull request Mar 11, 2024
🤖 I have created a release *beep* *boop*
---


##
[4.0.1](testcontainers-v4.0.0...testcontainers-v4.0.1)
(2024-03-11)


### Features

* **postgres:** Remove SqlAlchemy dependency from postgres container
([#445](#445))
([f30eb1d](f30eb1d))


### Bug Fixes

* **clickhouse:** clickhouse waiting
([#428](#428))
([902a5a3](902a5a3))
* Close docker client when stopping the docker container
([#380](#380))
([efb1683](efb1683))
* failing tests for elasticsearch on machines with ARM CPU
([#454](#454))
([701b23a](701b23a))
* go back to 4.0.1
([#465](#465))
([1ac8c24](1ac8c24))
* **mongodb:** waiting for container to start (it was not waiting at all
before?)
([#461](#461))
([2c4f171](2c4f171))
* unclosed socket warning in db containers
([#378](#378))
([cd90aa7](cd90aa7))
* Update the copyright header for readthedocs
([#341](#341))
([5bef18a](5bef18a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Ankin <[email protected]>
bearrito pushed a commit to bearrito/testcontainers-python that referenced this pull request Mar 30, 2024
🤖 I have created a release *beep* *boop*
---


##
[4.0.1](testcontainers/testcontainers-python@testcontainers-v4.0.0...testcontainers-v4.0.1)
(2024-03-11)


### Features

* **postgres:** Remove SqlAlchemy dependency from postgres container
([testcontainers#445](testcontainers#445))
([f30eb1d](testcontainers@f30eb1d))


### Bug Fixes

* **clickhouse:** clickhouse waiting
([testcontainers#428](testcontainers#428))
([902a5a3](testcontainers@902a5a3))
* Close docker client when stopping the docker container
([testcontainers#380](testcontainers#380))
([efb1683](testcontainers@efb1683))
* failing tests for elasticsearch on machines with ARM CPU
([testcontainers#454](testcontainers#454))
([701b23a](testcontainers@701b23a))
* **mongodb:** waiting for container to start (it was not waiting at all
before?)
([testcontainers#461](testcontainers#461))
([2c4f171](testcontainers@2c4f171))
* unclosed socket warning in db containers
([testcontainers#378](testcontainers#378))
([cd90aa7](testcontainers@cd90aa7))
* Update the copyright header for readthedocs
([testcontainers#341](testcontainers#341))
([5bef18a](testcontainers@5bef18a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Ankin <[email protected]>
bearrito pushed a commit to bearrito/testcontainers-python that referenced this pull request Mar 30, 2024
🤖 I have created a release *beep* *boop*
---


##
[4.0.1](testcontainers/testcontainers-python@testcontainers-v4.0.0...testcontainers-v4.0.1)
(2024-03-11)


### Features

* **postgres:** Remove SqlAlchemy dependency from postgres container
([testcontainers#445](testcontainers#445))
([f30eb1d](testcontainers@f30eb1d))


### Bug Fixes

* **clickhouse:** clickhouse waiting
([testcontainers#428](testcontainers#428))
([902a5a3](testcontainers@902a5a3))
* Close docker client when stopping the docker container
([testcontainers#380](testcontainers#380))
([efb1683](testcontainers@efb1683))
* failing tests for elasticsearch on machines with ARM CPU
([testcontainers#454](testcontainers#454))
([701b23a](testcontainers@701b23a))
* go back to 4.0.1
([testcontainers#465](testcontainers#465))
([1ac8c24](testcontainers@1ac8c24))
* **mongodb:** waiting for container to start (it was not waiting at all
before?)
([testcontainers#461](testcontainers#461))
([2c4f171](testcontainers@2c4f171))
* unclosed socket warning in db containers
([testcontainers#378](testcontainers#378))
([cd90aa7](testcontainers@cd90aa7))
* Update the copyright header for readthedocs
([testcontainers#341](testcontainers#341))
([5bef18a](testcontainers@5bef18a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Ankin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants