code: def main():
      parser = argparse.ArgumentParser()
  
      subparsers = parser.add_subparsers(dest="command")
      client = subparsers.add_parser("client", help="Run the client.")
      client.add_argument("server")
      client.add_argument("--request-id", default=None)
  
      server = subparsers.add_parser("server", help="Run the server.")
      server.add_argument(
          "--listen",
          required=True,
          help="The location to listen on (example: grpc://localhost:5050)",
      )
      server.add_argument(
          "--delegate",
          required=False,
          default=None,
          help=(
              "A location to delegate to. That is, this server will "
              "simply call the given server for the response. Demonstrates "
              "propagation of the trace ID between servers."
          ),
      )
  
      args = parser.parse_args()
      if not getattr(args, "command"):
          parser.print_help()
          return 1
  
      if args.command == "server":
          server = FlightServer(
              args.delegate,
              location=args.listen,
              middleware={"trace": TracingServerMiddlewareFactory()},
          )
          server.serve()
      elif args.command == "client":
          client = flight.connect(
              args.server,
              middleware=(TracingClientMiddlewareFactory(),),
          )
          if args.request_id:
              TraceContext.set_trace_id(args.request_id)
          else:
              TraceContext.set_trace_id("client-chosen-id")
  
          for result in client.do_action(
              flight.Action("get-trace-id", b"")
          ):
              print(result.body.to_pybytes())
  
imports: import argparse
  import sys
  import threading
  import uuid
  import pyarrow
  import pyarrow.flight
label_desc: Use image node_id 1 for calling a global function with example usage: main() and returns: int