# Buggy code
def handle_routine(self, que, opts, host, target):
    """
    Run the routine in a "Thread", put a dict on the queue
    """
    opts = copy.deepcopy(opts)
    single = Single(
        opts, opts["argv"], host, mods=self.mods, fsclient=self.fsclient, **target
    )
    ret = {"id": single.id}
    stdout, stderr, retcode = single.run()
    # This job is done, yield
    try:
        data = salt.utils.find_json(stdout)
        if len(data) < 2 and "local" in data:
            ret["ret"] = data["local"]
        else:
            ret["ret"] = {
                "stdout": stdout,
                "stderr": stderr,
                "retcode": retcode,
            }
    except Exception:
        ret["ret"] = {
            "stdout": stdout,
            "stderr": stderr,
            "retcode": retcode,
        }
    que.put(ret)


# Traceback (IOError)
Process Process-8:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python2.7/dist-packages/salt/client/ssh/__init__.py", line 315, in handle_routine
stdout, stderr, retcode = single.run()
File "/usr/lib/python2.7/dist-packages/salt/client/ssh/__init__.py", line 630, in run
stdout = self.run_wfunc()
File "/usr/lib/python2.7/dist-packages/salt/client/ssh/__init__.py", line 675, in run_wfunc
opts_pkg = pre_wrapper['test.opts_pkg']()
File "/usr/lib/python2.7/dist-packages/salt/client/ssh/wrapper/__init__.py", line 62, in caller
stdout, stderr, _ = single.cmd_block()
File "/usr/lib/python2.7/dist-packages/salt/client/ssh/__init__.py", line 818, in cmd_block
cmd_str = self._cmd_str()
File "/usr/lib/python2.7/dist-packages/salt/client/ssh/__init__.py", line 755, in _cmd_str
thin_sum = salt.utils.thin.thin_sum(cachedir, 'sha1')
File "/usr/lib/python2.7/dist-packages/salt/utils/thin.py", line 182, in thin_sum
thintar = gen_thin(cachedir)
File "/usr/lib/python2.7/dist-packages/salt/utils/thin.py", line 172, in gen_thin
tfp.add('version')
File "/usr/lib/python2.7/tarfile.py", line 1995, in add
self.addfile(tarinfo, f)
File "/usr/lib/python2.7/tarfile.py", line 2024, in addfile
copyfileobj(fileobj, self.fileobj, tarinfo.size)
File "/usr/lib/python2.7/tarfile.py", line 279, in copyfileobj
raise IOError("end of file reached")
IOError: end of file reached

Traceback (most recent call last):
File "./install.py", line 415, in <module>
for output in run():
File "./install.py", line 331, in run
for output in bootstrap('*'):
File "./install.py", line 181, in bootstrap
yield check_output(['salt-ssh', minion_id, 'state.sls', 'bootstrap'])
File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['salt-ssh', '*', 'state.sls', 'bootstrap']' returned non-zero exit status -15

# Fixed code
def handle_routine(self, que, opts, host, target):
    """
    Run the routine in a "Thread", put a dict on the queue
    """
    opts = copy.deepcopy(opts)
    single = Single(
        opts,
        opts["argv"],
        host,
        mods=self.mods,
        fsclient=self.fsclient,
        thin=self.thin,
        **target,
    )
    ret = {"id": single.id}
    stdout, stderr, retcode = single.run()
    # This job is done, yield
    try:
        data = salt.utils.find_json(stdout)
        if len(data) < 2 and "local" in data:
            ret["ret"] = data["local"]
        else:
            ret["ret"] = {
                "stdout": stdout,
                "stderr": stderr,
                "retcode": retcode,
            }
    except Exception:
        ret["ret"] = {
            "stdout": stdout,
            "stderr": stderr,
            "retcode": retcode,
        }
    que.put(ret)