Skip to content

unclosed socket in python3 #55

@jvanasco

Description

@jvanasco

In a few unittests, I started getting unclosed socket errors.

I may be leveraging this in unintended ways, as I created a Server() object and start/stop it manually.

The issue seems to be on Py3 (3.6 to be exact) the call to stop() doesn't close the socket on wsgiref, if a request has been made to it already. (Related #28 )

I've adjusted my tests to invoke _server.socket.close() after calling _server.stop(). I'm not sure if this is necessary in all usage of this package. If so, it may make sense to adjust the stop() method to call socket.close()

https://github.com/kevin1024/pytest-httpbin/blob/master/pytest_httpbin/serve.py#L117-L118

    def stop(self):
        self._server.shutdown()
+       self._server.socket.close()        

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions