@contextmanager
def serving(resources):
 (server, port) = server_and_port(resources)
 thread = Thread(target=server.serve_forever)
 try:
  thread.start()
  (yield 'https://localhost:{port}/'.format(port=port))
 finally:
  server.shutdown()
  thread.join()

@ contextmanager def serving ( resources ) : ( server , port ) = server_and_port ( resources ) thread = Thread ( target = server . serve_forever ) try : thread . start ( ) ( yield 'https://localhost:{port}/' . format ( port = port ) ) finally : server . shutdown ( ) thread . join ( )
spin up a local https server .