code: def setup_limits(conf_file, limits_file, do_reload=True,
                   dry_run=False, debug=False):
      if dry_run:
          debug = True
      conf = config.Config(conf_file=conf_file)
      db = conf.get_database()
      limits_key = conf['control'].get('limits_key', 'limits')
      control_channel = conf['control'].get('channel', 'control')
      limits_tree = etree.parse(limits_file)
      lims = []
      for idx, lim in enumerate(limits_tree.getroot()):
          if lim.tag != 'limit':
              warnings.warn("Unrecognized tag %r in limits file at index %d" %
                            (lim.tag, idx))
              continue
          try:
              lims.append(parse_limit_node(db, idx, lim))
          except Exception as exc:
              warnings.warn("Couldn't understand limit at index %d: %s" %
                            (idx, exc))
              continue
      if debug:
          print >>sys.stderr, "Installing the following limits:"
          for lim in lims:
              print >>sys.stderr, "  %r" % lim
      if not dry_run:
          database.limit_update(db, limits_key, lims)
      if do_reload is False:
          return
      params = []
      if do_reload is True:
          pass
      elif (isinstance(do_reload, (int, long, float)) or
            (isinstance(do_reload, basestring) and do_reload.isdigit())):
          params = ['spread', do_reload]
      else:
          params = [str(do_reload)]
      if debug:
          cmd = ['reload']
          cmd.extend(params)
          print >>sys.stderr, ("Issuing command: %s" %
                               ' '.join(str(c) for c in cmd))
      if not dry_run:
          database.command(db, control_channel, 'reload', *params)