# Buggy code
def _serialiseJob(self, jobStore, jobsToJobWrappers, rootJobWrapper):
    """
    Pickle a job and its jobWrapper to disk.
    """
    # Pickle the job so that its run method can be run at a later time.
    # Drop out the children/followOns/predecessors/services - which are
    # all recorded within the jobStore and do not need to be stored within
    # the job
    self._children = []
    self._followOns = []
    self._services = []
    self._directPredecessors = set()
    # The pickled job is "run" as the command of the job, see worker
    # for the mechanism which unpickles the job and executes the Job.run
    # method.
    with jobStore.writeFileStream(rootJobWrapper.jobStoreID) as (
        fileHandle,
        fileStoreID,
    ):
        cPickle.dump(self, fileHandle, cPickle.HIGHEST_PROTOCOL)
    jobsToJobWrappers[self].command = " ".join(
        ("_toil", fileStoreID) + self.userModule.globalize()
    )
    # Update the status of the jobWrapper on disk
    jobStore.update(jobsToJobWrappers[self])


# Traceback (AttributeError)
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:   ---TOIL WORKER OUTPUT LOG---
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:   Next available file descriptor: 5
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:   DEBUG:__main__:Next available file descriptor: 5
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:   Parsed job
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:   DEBUG:__main__:Parsed job
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:   Traceback (most recent call last):
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:     File "/usr/local/lib/python2.7/dist-packages/toil/worker.py", line 238, in main
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:       jobStore)._execute( jobWrapper=job,
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:     File "/usr/local/lib/python2.7/dist-packages/toil/job.py", line 555, in _loadJob
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:       return cls._unpickle(userModule, fileHandle)
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:     File "/usr/local/lib/python2.7/dist-packages/toil/job.py", line 576, in _unpickle
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:       return unpickler.load()
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:     File "/usr/local/lib/python2.7/dist-packages/toil/job.py", line 571, in filter_main
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:       return getattr(userModule, class_name)
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:   AttributeError: 'module' object has no attribute 'AzureIOStore'
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:   Exiting the worker because of a failed job on host hgvmclusteragent1
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:   ERROR:__main__:Exiting the worker because of a failed job on host hgvmclusteragent1
WARNING:toil.leader:732fd38e_d585_4405_8d6b_c37a982f1ba5:   WARNING:toil.jobWrapper:Due to failure we are reducing the remaining retry count of job 732fd38e_d585_4405_8d6b_c37a982f1ba5 to 0

# Fixed code
def _serialiseJob(self, jobStore, jobsToJobWrappers, rootJobWrapper):
    """
    Pickle a job and its jobWrapper to disk.
    """
    # Pickle the job so that its run method can be run at a later time.
    # Drop out the children/followOns/predecessors/services - which are
    # all recorded within the jobStore and do not need to be stored within
    # the job
    self._children = []
    self._followOns = []
    self._services = []
    self._directPredecessors = set()
    # The pickled job is "run" as the command of the job, see worker
    # for the mechanism which unpickles the job and executes the Job.run
    # method.
    with jobStore.writeFileStream(rootJobWrapper.jobStoreID) as (
        fileHandle,
        fileStoreID,
    ):
        cPickle.dump(self, fileHandle, cPickle.HIGHEST_PROTOCOL)
    # Note that getUserScript() may have beeen overridden. This is intended. If we used
    # self.userModule directly, we'd be getting a reference to job.py if the job was
    # specified as a function (as opposed to a class) since that is where FunctionWrappingJob
    #  is defined. What we really want is the module that was loaded as __main__,
    # and FunctionWrappingJob overrides getUserScript() to give us just that. Only then can
    # filter_main() in _unpickle( ) do its job of resolveing any user-defined type or function.
    userScript = self.getUserScript().globalize()
    jobsToJobWrappers[self].command = " ".join(("_toil", fileStoreID) + userScript)
    # Update the status of the jobWrapper on disk
    jobStore.update(jobsToJobWrappers[self])