On Thursday, 20 September 2018 10:50:14 CEST Richard W.M. Jones wrote: > +# Choose a random port number in range [50000,59999] > +imageio_port = random.randint(50000,60000) > + > [...] > + > +def server(): > + server_address = ("", imageio_port) > + httpd = HTTPServer(server_address, RequestHandler) > + httpd.serve_forever()
The random port can be chosen directly by the OS, using the special port 0: >>> from http.server import HTTPServer, SimpleHTTPRequestHandler >>> server_address = ("", 0) >>> httpd = HTTPServer(server_address, SimpleHTTPRequestHandler) >>> print(httpd.server_address) ('0.0.0.0', 44725) -- Pino Toscano
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs