[Libguestfs] [PATCH v2 3/3] v2v: -o rhv-upload: Add a test.

Pino Toscano ptoscano at redhat.com
Wed Sep 26 17:40:08 UTC 2018


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20180926/e764b99f/attachment.sig>


More information about the Libguestfs mailing list