# Buggy code
def __init__(self, name, job_def, job_queue, log_backend, container_overrides):
    """
    Docker Job

    :param name: Job Name
    :param job_def: Job definition
    :type: job_def: JobDefinition
    :param job_queue: Job Queue
    :param log_backend: Log backend
    :type log_backend: moto.logs.models.LogsBackend
    """
    threading.Thread.__init__(self)

    self.job_name = name
    self.job_id = str(uuid.uuid4())
    self.job_definition = job_def
    self.container_overrides = container_overrides
    self.job_queue = job_queue
    self.job_state = "SUBMITTED"  # One of SUBMITTED | PENDING | RUNNABLE | STARTING | RUNNING | SUCCEEDED | FAILED
    self.job_queue.jobs.append(self)
    self.job_started_at = datetime.datetime(1970, 1, 1)
    self.job_stopped_at = datetime.datetime(1970, 1, 1)
    self.job_stopped = False
    self.job_stopped_reason = None

    self.stop = False

    self.daemon = True
    self.name = "MOTO-BATCH-" + self.job_id

    self.docker_client = docker.from_env()
    self._log_backend = log_backend

    # Unfortunately mocking replaces this method w/o fallback enabled, so we
    # need to replace it if we detect it's been mocked
    if requests.adapters.HTTPAdapter.send != _orig_adapter_send:
        _orig_get_adapter = self.docker_client.api.get_adapter

        def replace_adapter_send(*args, **kwargs):
            adapter = _orig_get_adapter(*args, **kwargs)

            if isinstance(adapter, requests.adapters.HTTPAdapter):
                adapter.send = functools.partial(_orig_adapter_send, adapter)
            return adapter

        self.docker_client.api.get_adapter = replace_adapter_send


# Traceback (AttributeError)
2020-02-28 23:16:27 - werkzeug     - INFO     - 127.0.0.1 - - [28/Feb/2020 23:16:27] "POST /v1/describejobs HTTP/1.1" 500 -
2020-02-28 23:16:27 - werkzeug     - ERROR    - Error on request:
Traceback (most recent call last):
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/werkzeug/serving.py", line 323, in run_wsgi
execute(self.server.app)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/werkzeug/serving.py", line 312, in execute
application_iter = app(environ, start_response)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/server.py", line 135, in __call__
return backend_app(environ, start_response)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/core/utils.py", line 144, in __call__
result = self.callback(request, request.url, {})
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/core/responses.py", line 197, in dispatch
return cls()._dispatch(*args, **kwargs)
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/core/responses.py", line 295, in _dispatch
return self.call_action()
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/core/responses.py", line 380, in call_action
response = method()
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/batch/responses.py", line 257, in describejobs
return json.dumps({"jobs": self.batch_backend.describe_jobs(jobs)})
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/batch/models.py", line 1229, in describe_jobs
result.append(job.describe())
File "/builds/dazza-codes/python-notes/.venv/lib/python3.6/site-packages/moto/batch/models.py", line 355, in describe
result["container"]["logStreamName"] = self.log_stream_name
AttributeError: 'Job' object has no attribute 'log_stream_name'

# Fixed code
def __init__(self, name, job_def, job_queue, log_backend, container_overrides):
    """
    Docker Job

    :param name: Job Name
    :param job_def: Job definition
    :type: job_def: JobDefinition
    :param job_queue: Job Queue
    :param log_backend: Log backend
    :type log_backend: moto.logs.models.LogsBackend
    """
    threading.Thread.__init__(self)

    self.job_name = name
    self.job_id = str(uuid.uuid4())
    self.job_definition = job_def
    self.container_overrides = container_overrides or {}
    self.job_queue = job_queue
    self.job_state = "SUBMITTED"  # One of SUBMITTED | PENDING | RUNNABLE | STARTING | RUNNING | SUCCEEDED | FAILED
    self.job_queue.jobs.append(self)
    self.job_started_at = datetime.datetime(1970, 1, 1)
    self.job_stopped_at = datetime.datetime(1970, 1, 1)
    self.job_stopped = False
    self.job_stopped_reason = None

    self.stop = False

    self.daemon = True
    self.name = "MOTO-BATCH-" + self.job_id

    self.docker_client = docker.from_env()
    self._log_backend = log_backend
    self.log_stream_name = None

    # Unfortunately mocking replaces this method w/o fallback enabled, so we
    # need to replace it if we detect it's been mocked
    if requests.adapters.HTTPAdapter.send != _orig_adapter_send:
        _orig_get_adapter = self.docker_client.api.get_adapter

        def replace_adapter_send(*args, **kwargs):
            adapter = _orig_get_adapter(*args, **kwargs)

            if isinstance(adapter, requests.adapters.HTTPAdapter):
                adapter.send = functools.partial(_orig_adapter_send, adapter)
            return adapter

        self.docker_client.api.get_adapter = replace_adapter_send