# Buggy code
def cmd_async(
    self, tgt, fun, arg=(), tgt_type="glob", ret="", jid="", kwarg=None, **kwargs
):
    """
    Asynchronously send a command to connected minions

    The function signature is the same as :py:meth:`cmd` with the
    following exceptions.

    :returns: A job ID or 0 on failure.

    .. code-block:: python

        >>> local.cmd_async('*', 'test.sleep', [300])
        '20131219215921857715'
    """
    if "expr_form" in kwargs:
        salt.utils.warn_until(
            "Fluorine",
            "The target type should be passed using the 'tgt_type' "
            "argument instead of 'expr_form'. Support for using "
            "'expr_form' will be removed in Salt Fluorine.",
        )
        tgt_type = kwargs.pop("expr_form")

    arg = salt.utils.args.condition_input(arg, kwarg)
    pub_data = self.run_job(tgt, fun, arg, tgt_type, ret, jid=jid, **kwargs)
    try:
        return pub_data["jid"]
    except KeyError:
        return 0


# Traceback (SaltClientError)
2017-03-20 15:58:15,317 [salt.utils.event                         ][DEBUG   ][28048] MasterEvent PUB socket URI: ipc:///var/run/salt/master/master_event_pub.ipc2017-03-20 15:58:15,318 [salt.utils.event                         ][DEBUG   ][28048] MasterEvent PULL socket URI: ipc:///var/run/salt/master/master_event_pull.ipc
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/netapi/rest_cherrypy/app.py", line 507, in hypermedia_handler
File "/usr/lib/python2.6/site-packages/cherrypy/_cpdispatch.py", line 34, in __call__
File "/usr/lib/python2.6/site-packages/salt/netapi/rest_cherrypy/app.py", line 933, in POST
File "/usr/lib/python2.6/site-packages/salt/netapi/rest_cherrypy/app.py", line 775, in exec_lowstate
File "/usr/lib/python2.6/site-packages/salt/netapi/__init__.py", line 70, in run
File "/usr/lib/python2.6/site-packages/salt/netapi/__init__.py", line 98, in local
File "/usr/lib/python2.6/site-packages/salt/client/__init__.py", line 535, in cmd
File "/usr/lib/python2.6/site-packages/salt/client/__init__.py", line 290, in run_job
SaltClientError: [Errno 24] Too many open files
2017-03-20 15:58:15,751 [salt.utils.process                       ][INFO    ][28040] Process <function start at 0x1ce6b18> (28048) died with exit status None, restarting...
2017-03-20 15:58:16,757 [salt.utils.process                       ][DEBUG   ][28040] Started 'salt.loaded.int.netapi.rest_cherrypy.start' with pid 20716

# Fixed code
def cmd_async(
    self, tgt, fun, arg=(), tgt_type="glob", ret="", jid="", kwarg=None, **kwargs
):
    """
    Asynchronously send a command to connected minions

    The function signature is the same as :py:meth:`cmd` with the
    following exceptions.

    :returns: A job ID or 0 on failure.

    .. code-block:: python

        >>> local.cmd_async('*', 'test.sleep', [300])
        '20131219215921857715'
    """
    if "expr_form" in kwargs:
        salt.utils.warn_until(
            "Fluorine",
            "The target type should be passed using the 'tgt_type' "
            "argument instead of 'expr_form'. Support for using "
            "'expr_form' will be removed in Salt Fluorine.",
        )
        tgt_type = kwargs.pop("expr_form")

    arg = salt.utils.args.condition_input(arg, kwarg)
    pub_data = self.run_job(
        tgt, fun, arg, tgt_type, ret, jid=jid, listen=False, **kwargs
    )
    try:
        return pub_data["jid"]
    except KeyError:
        return 0