pika_perf.py
def _handlePublishTest(args):
  """ Parse args and invoke the publish test using the requested connection
  class

  :param args: sequence of commandline args passed after the "publish" keyword
  """
  helpString = (
    "\n"
    "\t%%prog publish OPTIONS\n"
    "\t%%prog publish --help\n"
    "\t%%prog --help\n"
    "\n"
    "Publishes the given number of messages of the\n"
    "given size to the given exchange and routing_key=%s using the specified\n"
    "pika connection class") % (ROUTING_KEY,)
  parser = OptionParser(helpString)

  implChoices = ["BlockingConnection",
                 "SynchronousConnection",
                 "SelectConnection"]
  parser.add_option(
      "--impl",
      action="store",
      type="choice",
      dest="impl",
      choices=implChoices,
      help=("Selection of pika connection class "
            "[REQUIRED; must be one of: %s]" % ", ".join(implChoices)))

  parser.add_option(
      "--exg",
      action="store",
      type="string",
      dest="exchange",
      help="Destination exchange [REQUIRED]")

  parser.add_option(
      "--msgs",
      action="store",
      type="int",
      dest="numMessages",
      default=1000,
      help="Number of messages to send [default: %default]")

  parser.add_option(
      "--size",
      action="store",
      type="int",
      dest="messageSize",
      default=1024,
      help="Size of each message in bytes [default: %default]")

  parser.add_option(
      "--pubacks",
      action="store_true",
      dest="deliveryConfirmation",
      default=False,
      help="Publish in delivery confirmation mode [defaults to OFF]")

  options, positionalArgs = parser.parse_args(sys.argv[2:])

  if positionalArgs:
    raise parser.error("Unexpected to have any positional args, but got: %r"
                       % positionalArgs)

  if not options.impl:
    parser.error("--impl is required")

  if options.exchange is None:
    parser.error("--exg must be specified with a valid destination exchange name")

  if options.impl in ["BlockingConnection", "SynchronousConnection"]:
    runBlockingPublishTest(implClassName=options.impl,
                           exchange=options.exchange,
                           numMessages=options.numMessages,
                           messageSize=options.messageSize,
                           deliveryConfirmation=options.deliveryConfirmation)
  else:
    assert options.impl == "SelectConnection", options.impl

    runSelectPublishTest(implClassName=options.impl,
                         exchange=options.exchange,
                         numMessages=options.numMessages,
                         messageSize=options.messageSize,
                         deliveryConfirmation=options.deliveryConfirmation)
 Parse args and invoke the publish test using the requested connection
  class

  :param args: sequence of commandline args passed after the "publish" keyword
  
Parse args and invoke the publish test using the requested connection
class
Parse args and invoke the publish test using the requested connection class
def _handlePublishTest(args):
  helpString = (
    "\n"
    "\t%%prog publish OPTIONS\n"
    "\t%%prog publish --help\n"
    "\t%%prog --help\n"
    "\n"
    "Publishes the given number of messages of the\n"
    "given size to the given exchange and routing_key=%s using the specified\n"
    "pika connection class") % (ROUTING_KEY,)
  parser = OptionParser(helpString)
  implChoices = ["BlockingConnection",
                 "SynchronousConnection",
                 "SelectConnection"]
  parser.add_option(
      "--impl",
      action="store",
      type="choice",
      dest="impl",
      choices=implChoices,
      help=("Selection of pika connection class "
            "[REQUIRED; must be one of: %s]" % ", ".join(implChoices)))
  parser.add_option(
      "--exg",
      action="store",
      type="string",
      dest="exchange",
      help="Destination exchange [REQUIRED]")
  parser.add_option(
      "--msgs",
      action="store",
      type="int",
      dest="numMessages",
      default=1000,
      help="Number of messages to send [default: %default]")
  parser.add_option(
      "--size",
      action="store",
      type="int",
      dest="messageSize",
      default=1024,
      help="Size of each message in bytes [default: %default]")
  parser.add_option(
      "--pubacks",
      action="store_true",
      dest="deliveryConfirmation",
      default=False,
      help="Publish in delivery confirmation mode [defaults to OFF]")
  options, positionalArgs = parser.parse_args(sys.argv[2:])
  if positionalArgs:
    raise parser.error("Unexpected to have any positional args, but got: %r"
                       % positionalArgs)
  if not options.impl:
    parser.error("--impl is required")
  if options.exchange is None:
    parser.error("--exg must be specified with a valid destination exchange name")
  if options.impl in ["BlockingConnection", "SynchronousConnection"]:
    runBlockingPublishTest(implClassName=options.impl,
                           exchange=options.exchange,
                           numMessages=options.numMessages,
                           messageSize=options.messageSize,
                           deliveryConfirmation=options.deliveryConfirmation)
  else:
    assert options.impl == "SelectConnection", options.impl
    runSelectPublishTest(implClassName=options.impl,
                         exchange=options.exchange,
                         numMessages=options.numMessages,
                         messageSize=options.messageSize,
                         deliveryConfirmation=options.deliveryConfirmation)
def _handlePublishTest ( args ) : helpString = ( "\n" "\t%%prog publish OPTIONS\n" "\t%%prog publish --help\n" "\t%%prog --help\n" "\n" "Publishes the given number of messages of the\n" "given size to the given exchange and routing_key=%s using the specified\n" "pika connection class" ) % ( ROUTING_KEY , ) parser = OptionParser ( helpString ) implChoices = [ "BlockingConnection" , "SynchronousConnection" , "SelectConnection" ] parser . add_option ( "--impl" , action = "store" , type = "choice" , dest = "impl" , choices = implChoices , help = ( "Selection of pika connection class " "[REQUIRED; must be one of: %s]" % ", " . join ( implChoices ) ) ) parser . add_option ( "--exg" , action = "store" , type = "string" , dest = "exchange" , help = "Destination exchange [REQUIRED]" ) parser . add_option ( "--msgs" , action = "store" , type = "int" , dest = "numMessages" , default = 1000 , help = "Number of messages to send [default: %default]" ) parser . add_option ( "--size" , action = "store" , type = "int" , dest = "messageSize" , default = 1024 , help = "Size of each message in bytes [default: %default]" ) parser . add_option ( "--pubacks" , action = "store_true" , dest = "deliveryConfirmation" , default = False , help = "Publish in delivery confirmation mode [defaults to OFF]" ) options , positionalArgs = parser . parse_args ( sys . argv [ 2 : ] ) if positionalArgs : raise parser . error ( "Unexpected to have any positional args, but got: %r" % positionalArgs ) if not options . impl : parser . error ( "--impl is required" ) if options . exchange is None : parser . error ( "--exg must be specified with a valid destination exchange name" ) if options . impl in [ "BlockingConnection" , "SynchronousConnection" ] : runBlockingPublishTest ( implClassName = options . impl , exchange = options . exchange , numMessages = options . numMessages , messageSize = options . messageSize , deliveryConfirmation = options . deliveryConfirmation ) else : assert options . impl == "SelectConnection" , options . impl runSelectPublishTest ( implClassName = options . impl , exchange = options . exchange , numMessages = options . numMessages , messageSize = options . messageSize , deliveryConfirmation = options . deliveryConfirmation )
Parse args and invoke the publish test using the requested connection
class
Parse args and invoke the publish test using the requested connection class
""" Parse args and invoke the publish test using the requested connection
  class

  :param args: sequence of commandline args passed after the "publish" keyword
  """
args
sequence of commandline args passed after the "publish" keyword
sequence of commandline args passed after the " publish " keyword