RefactoringRope/JsonClient.py

changeset 354
a967ff16629a
parent 347
b5048b5ff454
equal deleted inserted replaced
353:d38295fd97c2 354:a967ff16629a
11 import sys 11 import sys
12 import socket 12 import socket
13 import select 13 import select
14 import traceback 14 import traceback
15 import json 15 import json
16 16 import contextlib
17 17
18 class JsonClient(object): 18
19 class JsonClient:
19 """ 20 """
20 Class implementing the JSON based client base class. 21 Class implementing the JSON based client base class.
21 """ 22 """
22 def __init__(self, host, port, idString=""): 23 def __init__(self, host, port, idString=""):
23 """ 24 """
149 "ExceptionValue": str(excval), 150 "ExceptionValue": str(excval),
150 "Traceback": tbinfo, 151 "Traceback": tbinfo,
151 }) 152 })
152 153
153 # Give time to process latest response on server side 154 # Give time to process latest response on server side
154 try: 155 with contextlib.suppress(socket.error, OSError):
155 self.__connection.shutdown(socket.SHUT_RDWR) 156 self.__connection.shutdown(socket.SHUT_RDWR)
156 self.__connection.close() 157 self.__connection.close()
157 except (socket.error, OSError):
158 # ignore these; socket might be closed already
159 pass
160 158
161 def poll(self, waitMethod=""): 159 def poll(self, waitMethod=""):
162 """ 160 """
163 Public method to check and receive one message (if available). 161 Public method to check and receive one message (if available).
164 162

eric ide

mercurial