Commit d6c21492 authored by Filip Široký's avatar Filip Široký Committed by Petr Špaček
Browse files

Use selectors instead of select

parent 1e55bd65
Pipeline #38975 passed with stage
in 1 minute and 34 seconds
......@@ -5,7 +5,7 @@ import itertools
import logging
import os
import signal
import select
import selectors
import socket
import sys
import threading
......@@ -126,8 +126,13 @@ class TestServer:
if not
objects = self.srv_socks + self.connections
to_read, _, to_error =, [], objects, 0.1)
for sock in to_read:
sel = selectors.DefaultSelector()
for obj in objects:
sel.register(obj, selectors.EVENT_READ)
items =
for key, event in items:
sock = key.fileobj
if event & selectors.EVENT_READ:
if sock in self.srv_socks:
if sock.proto == socket.IPPROTO_TCP:
conn, _ = sock.accept()
......@@ -140,9 +145,11 @@ class TestServer:
raise Exception(
"[query_io] Socket IO internal error {}, exit".format(sock.getsockname()))
for sock in to_error:
raise Exception("[query_io] Socket IO error {}, exit".format(sock.getsockname()))
"[query_io] Socket IO internal error {}, exit"
raise Exception("[query_io] Socket IO error {}, exit"
def start_srv(self, address, family, proto=socket.IPPROTO_UDP):
""" Starts listening thread if necessary """
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment