Skip to content
Myr

Made TestServer.Server listen on an arbitrary open port by default

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Braulio Valdivielso Martínez · committed by Braulio Valdivielso Martínez · parent 47e96c4 · Browse files · 2 files+5 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+5 added−2 removed

  • other:+5 added−2 removed

2 files+5 added−2 removed

deleted:testserver/.server.py.swobinary

A binary file, deleted.

modified:testserver/server.py+5 added-2 removed
1 unmodified line
23import threading, socket45class Server(threading.Thread):6 """ Basic socket server used for unit testing """6 """ Dummy server using for unit testing """78 def __init__(self, handler, host='localhost', port=8021):8 def __init__(self, handler, host='localhost', port=0):9 threading.Thread.__init__(self)10 self.handler = handler11 self.host = host12 self.port = port
2 unmodified lines
1516 def run(self):17 sock = socket.socket()18 sock.bind((self.host, self.port))19 20 # update port in case self.port = 021 self.port = sock.getsockname()[1]22 sock.listen(0)23 self.ready_event.set()24 self.handler(sock)25 self.stop_event.set()
12 unmodified lines