# Buggy code
def worker(self, inputQueue):
    while True:
        args = inputQueue.get()
        if args is None:
            log.debug("Received queue sentinel.")
            break
        jobCommand, jobID, jobCores, jobMemory, jobDisk = args
        try:
            coreFractions = int(jobCores / self.minCores)
            log.debug(
                "Acquiring %i bytes of memory from a pool of %s.",
                jobMemory,
                self.memory,
            )
            with self.memory.acquisitionOf(jobMemory):
                log.debug(
                    "Acquiring %i fractional cores from a pool of %s to satisfy a "
                    "request of %f cores",
                    coreFractions,
                    self.coreFractions,
                    jobCores,
                )
                with self.coreFractions.acquisitionOf(coreFractions):
                    log.info("Executing command: '%s'.", jobCommand)
                    with self.popenLock:
                        popen = subprocess.Popen(jobCommand, shell=True)
                    statusCode = None
                    info = Info(time.time(), popen, killIntended=False)
                    try:
                        self.runningJobs[jobID] = info
                        try:
                            statusCode = popen.wait()
                            if 0 != statusCode:
                                if statusCode != -9 or not info.killIntended:
                                    log.error(
                                        "Got exit code %i (indicating failure) from "
                                        "command '%s'.",
                                        statusCode,
                                        jobCommand,
                                    )
                        finally:
                            self.runningJobs.pop(jobID)
                    finally:
                        if statusCode is not None and not info.killIntended:
                            self.outputQueue.put((jobID, statusCode))
        finally:
            log.debug(
                "Finished job. self.coreFractions ~ %s and self.memory ~ %s",
                self.coreFractions.value,
                self.memory.value,
            )
    log.debug("Exiting worker thread normally.")


# Traceback (ConfigParser.NoSectionError)
DEBUG:toil.batchSystems.mesos.executor:Starting executor
I0924 22:47:08.587648 43191 exec.cpp:132] Version: 0.22.0
I0924 22:47:08.592193 43192 exec.cpp:206] Executor registered on slave 20150924-214557-83886090-5050-44087-S8
INFO:toil.batchSystems.mesos.executor:Registered with framework
DEBUG:toil.batchSystems.mesos.executor:Running task 0
DEBUG:toil.batchSystems.mesos.executor:Sending status update ...
DEBUG:toil.batchSystems.mesos.executor:Sent status update
DEBUG:toil.batchSystems.mesos.executor:Invoking command: '/usr/bin/python2.7 -E /usr/local/lib/python2.7/dist-packages/toil/worker.py azure:hgvm:tree2 683b1010_55c3_4978_a7e7_853f17ed1803'
DEBUG:toil.batchSystems.mesos.executor:Sent stats message
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/toil/worker.py", line 408, in <module>
main()
File "/usr/local/lib/python2.7/dist-packages/toil/worker.py", line 89, in main
jobStore = loadJobStore(jobStoreString)
File "/usr/local/lib/python2.7/dist-packages/toil/common.py", line 366, in loadJobStore
return AzureJobStore( account, namePrefix, config=config )
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/azureJobStore.py", line 78, in __init__
account_key = _fetchAzureAccountKey(accountName)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/azureJobStore.py", line 63, in _fetchAzureAccountKey
return configParser.get('AzureStorageCredentials', accountName)
File "/usr/lib/python2.7/ConfigParser.py", line 330, in get
raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'AzureStorageCredentials'
DEBUG:toil.batchSystems.mesos.executor:Sending status update ...
DEBUG:toil.batchSystems.mesos.executor:Sent status update
I0924 22:47:09.738494 43200 exec.cpp:379] Executor asked to shutdown
CRITICAL:toil.batchSystems.mesos.executor:Shutting down executor...
CRITICAL:toil.batchSystems.mesos.executor:Executor shut down

# Fixed code
def worker(self, inputQueue):
    while True:
        args = inputQueue.get()
        if args is None:
            log.debug("Received queue sentinel.")
            break
        jobCommand, jobID, jobCores, jobMemory, jobDisk, environment = args
        try:
            coreFractions = int(jobCores / self.minCores)
            log.debug(
                "Acquiring %i bytes of memory from a pool of %s.",
                jobMemory,
                self.memory,
            )
            with self.memory.acquisitionOf(jobMemory):
                log.debug(
                    "Acquiring %i fractional cores from a pool of %s to satisfy a "
                    "request of %f cores",
                    coreFractions,
                    self.coreFractions,
                    jobCores,
                )
                with self.coreFractions.acquisitionOf(coreFractions):
                    log.info("Executing command: '%s'.", jobCommand)
                    with self.popenLock:
                        popen = subprocess.Popen(
                            jobCommand, shell=True, env=dict(os.environ, **environment)
                        )
                    statusCode = None
                    info = Info(time.time(), popen, killIntended=False)
                    try:
                        self.runningJobs[jobID] = info
                        try:
                            statusCode = popen.wait()
                            if 0 != statusCode:
                                if statusCode != -9 or not info.killIntended:
                                    log.error(
                                        "Got exit code %i (indicating failure) from "
                                        "command '%s'.",
                                        statusCode,
                                        jobCommand,
                                    )
                        finally:
                            self.runningJobs.pop(jobID)
                    finally:
                        if statusCode is not None and not info.killIntended:
                            self.outputQueue.put((jobID, statusCode))
        finally:
            log.debug(
                "Finished job. self.coreFractions ~ %s and self.memory ~ %s",
                self.coreFractions.value,
                self.memory.value,
            )
    log.debug("Exiting worker thread normally.")