MCPcopy
hub / github.com/shadowsocks/shadowsocks / run

Method run

shadowsocks/eventloop.py:193–223  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

191 self._stopping = True
192
193 def run(self):
194 events = []
195 while not self._stopping:
196 asap = False
197 try:
198 events = self.poll(TIMEOUT_PRECISION)
199 except (OSError, IOError) as e:
200 if errno_from_exception(e) in (errno.EPIPE, errno.EINTR):
201 # EPIPE: Happens when the client closes the connection
202 # EINTR: Happens when received a signal
203 # handles them as soon as possible
204 asap = True
205 logging.debug('poll:%s', e)
206 else:
207 logging.error('poll:%s', e)
208 traceback.print_exc()
209 continue
210
211 for sock, fd, event in events:
212 handler = self._fdmap.get(fd, None)
213 if handler is not None:
214 handler = handler[1]
215 try:
216 handler.handle_event(sock, fd, event)
217 except (OSError, IOError) as e:
218 shell.print_exception(e)
219 now = time.time()
220 if asap or now - self._last_time >= TIMEOUT_PRECISION:
221 for callback in self._periodic_callbacks:
222 callback()
223 self._last_time = now
224
225 def __del__(self):
226 self._impl.close()

Callers 3

mainFunction · 0.95
testFunction · 0.95
run_serverFunction · 0.95

Calls 5

pollMethod · 0.95
errno_from_exceptionFunction · 0.85
callbackFunction · 0.85
getMethod · 0.80
handle_eventMethod · 0.45

Tested by

no test coverage detected