This is an archive of the discontinued Mercurial Phabricator instance.

tests: change how sockets are closed
ClosedPublic

Authored by indygreg on Jan 30 2019, 3:56 PM.

Details

Summary

Python 3 uses a different type to represent a socket file object
than Python 2. We need to conditionalize how the socket is closed
accordingly.

While we're here, we switch to use socket.shutdown() to close the
socket. This is because socket.close() may not actually close
the socket until it is GCd. socket.shutdown() forces an immediate
shutdown.

I suspect Python 3 changed semantic behavior here, as I can't get
test-http-bad-server.t to work with socket.close(). socket.shutdown()
does appear to work, however.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Jan 30 2019, 3:56 PM
durin42 added inline comments.
tests/badserverext.py
140

pycompat.ispy3

indygreg updated this revision to Diff 13585.Jan 30 2019, 4:09 PM
This revision was automatically updated to reflect the committed changes.