

@util.synchronized('watcher_set_opt')
def set_opt(self, key, val):
    'Set a watcher option.\n\n        This function set the watcher options. unknown keys are ignored.\n        This function return an action number:\n\n        - 0: trigger the process management\n        - 1: trigger a graceful reload of the processes;\n        '
    action = 0
    if (key in self._options):
        self._options[action] = val
        action = (- 1)
    elif (key == 'numprocesses'):
        val = int(val)
        if (val < 0):
            val = 0
        if (self.singleton and (val > 1)):
            raise ValueError('Singleton watcher has a single process')
        self.numprocesses = val
    elif (key == 'warmup_delay'):
        self.warmup_delay = float(val)
    elif (key == 'working_dir'):
        self.working_dir = val
        action = 1
    elif (key == 'uid'):
        self.uid = util.to_uid(val)
        action = 1
    elif (key == 'gid'):
        self.gid = util.to_gid(val)
        action = 1
    elif (key == 'send_hup'):
        self.send_hup = val
    elif (key == 'stop_signal'):
        self.stop_signal = util.to_signum(val)
    elif (key == 'stop_children'):
        self.stop_children = util.to_bool(val)
    elif (key == 'shell'):
        self.shell = val
        action = 1
    elif (key == 'env'):
        if (PY2 and IS_WINDOWS):
            self.env = dict(((b(k), b(v)) for (k, v) in val.iteritems()))
        else:
            self.env = val
        action = 1
    elif (key == 'cmd'):
        self.cmd = val
        action = 1
    elif (key == 'args'):
        self.args = val
        action = 1
    elif (key == 'graceful_timeout'):
        self.graceful_timeout = float(val)
        action = (- 1)
    elif (key == 'max_age'):
        self.max_age = int(val)
        action = 1
    elif (key == 'max_age_variance'):
        self.max_age_variance = int(val)
        action = 1
    elif (key.startswith('stdout_stream') or key.startswith('stderr_stream')):
        action = self._reload_stream(key, val)
    elif key.startswith('hooks'):
        val = val.split(',')
        if (len(val) == 2):
            ignore_error = util.to_bool(val[1])
        else:
            ignore_error = False
        hook = val[0]
        self._reload_hook(key, hook, ignore_error)
        action = 0
    self.notify_event('updated', {
        'time': time.time(),
    })
    return action

dataset/ETHPy150Open circus-tent/circus/circus/watcher.py Watcher.set_opt/VarMisuse@43/147 `key`->`action`