Skip to content

'NoneType' object does not support the context manager protocol #1249

Open
@hank205

Description

@hank205

Describe your environment. Describe any aspect of your environment relevant to the problem, including your Python version, platform, version numbers of installed dependencies, information about your cloud hosting provider, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on master.
Python 3.13.2
opencensus-ext-azure 1.1.14

Steps to reproduce.
Describe exactly how to reproduce the error. Include a code sample if applicable.

import logging

from opencensus.ext.azure.log_exporter import AzureLogHandler

logger = logging.getLogger(__name__)
logger.addHandler(AzureLogHandler(connection_string='InstrumentationKey=<your-instrumentation_key-here>'))
logger.warning('Hello, World!')

What is the expected behavior?
What did you expect to see?
Log the message, no exception.

What is the actual behavior?
What did you see instead?
Message logged, followed by exception.

    logger.warning('Hello, World!')
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python313\Lib\logging\__init__.py", line 1531, in warning
    self._log(WARNING, msg, args, **kwargs)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python313\Lib\logging\__init__.py", line 1664, in _log
    self.handle(record)
    ~~~~~~~~~~~^^^^^^^^
  File "C:\Program Files\Python313\Lib\logging\__init__.py", line 1680, in handle
    self.callHandlers(record)
    ~~~~~~~~~~~~~~~~~^^^^^^^^
  File "C:\Program Files\Python313\Lib\logging\__init__.py", line 1736, in callHandlers
    hdlr.handle(record)
    ~~~~~~~~~~~^^^^^^^^
  File "C:\Program Files\Python313\Lib\logging\__init__.py", line 1025, in handle
    with self.lock:
         ^^^^^^^^^
TypeError: 'NoneType' object does not support the context manager protocol

Additional context.
Add any other context about the problem here.
There is an open PR related to this: #1248

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions