Skip to content
This repository has been archived by the owner on Aug 21, 2020. It is now read-only.

Commit

Permalink
Better way to shutdown the socket under python3
Browse files Browse the repository at this point in the history
Fixes the test_sequential_watch_prefix_once functional test under
python 3.x
  • Loading branch information
dims committed Aug 31, 2017
1 parent 980545f commit f30a4c5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion etcd3gw/watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# under the License.

import json
import six
import socket

from etcd3gw.utils import _decode
from etcd3gw.utils import _encode
Expand Down Expand Up @@ -63,7 +65,14 @@ def __init__(self, client, key, callback, **kwargs):

def stop(self):
try:
self._response.raw._fp.close()
if six.PY2:
self._response.raw._fp.close()
else:
s = socket.fromfd(self._response.raw._fp.fileno(),
socket.AF_INET,
socket.SOCK_STREAM)
s.shutdown(socket.SHUT_RDWR)
s.close()
except Exception:
pass
self._response.connection.close()
Expand Down

0 comments on commit f30a4c5

Please sign in to comment.