##// END OF EJS Templates
commandserver: loop over selector events...
Yuya Nishihara -
r40914:2525faf4 default
parent child Browse files
Show More
@@ -541,7 +541,8 b' class unixforkingservice(object):'
541 exiting = False
541 exiting = False
542 h = self._servicehandler
542 h = self._servicehandler
543 selector = selectors.DefaultSelector()
543 selector = selectors.DefaultSelector()
544 selector.register(self._sock, selectors.EVENT_READ)
544 selector.register(self._sock, selectors.EVENT_READ,
545 self._acceptnewconnection)
545 while True:
546 while True:
546 if not exiting and h.shouldexit():
547 if not exiting and h.shouldexit():
547 # clients can no longer connect() to the domain socket, so
548 # clients can no longer connect() to the domain socket, so
@@ -552,20 +553,21 b' class unixforkingservice(object):'
552 self._unlinksocket()
553 self._unlinksocket()
553 exiting = True
554 exiting = True
554 try:
555 try:
555 ready = selector.select(timeout=h.pollinterval)
556 events = selector.select(timeout=h.pollinterval)
556 except OSError as inst:
557 except OSError as inst:
557 # selectors2 raises ETIMEDOUT if timeout exceeded while
558 # selectors2 raises ETIMEDOUT if timeout exceeded while
558 # handling signal interrupt. That's probably wrong, but
559 # handling signal interrupt. That's probably wrong, but
559 # we can easily get around it.
560 # we can easily get around it.
560 if inst.errno != errno.ETIMEDOUT:
561 if inst.errno != errno.ETIMEDOUT:
561 raise
562 raise
562 ready = []
563 events = []
563 if not ready:
564 if not events:
564 # only exit if we completed all queued requests
565 # only exit if we completed all queued requests
565 if exiting:
566 if exiting:
566 break
567 break
567 continue
568 continue
568 self._acceptnewconnection(self._sock, selector)
569 for key, _mask in events:
570 key.data(key.fileobj, selector)
569 selector.close()
571 selector.close()
570
572
571 def _acceptnewconnection(self, sock, selector):
573 def _acceptnewconnection(self, sock, selector):
General Comments 0
You need to be logged in to leave comments. Login now