Skip to content

fix: always initialize _lock in Metric.__init__#1187

Closed
muhamedfazalps wants to merge 1 commit into
prometheus:masterfrom
muhamedfazalps:fix/always-init-lock
Closed

fix: always initialize _lock in Metric.__init__#1187
muhamedfazalps wants to merge 1 commit into
prometheus:masterfrom
muhamedfazalps:fix/always-init-lock

Conversation

@muhamedfazalps

Copy link
Copy Markdown

Fixes #1140

When a metric has no labels (neither parent nor observable), self._lock was never created, causing AttributeError when clear() or other methods try to access it.

Fix: Initialize self._lock = Lock() unconditionally before the _is_parent() check.

385 tests pass, 11 skipped.

When a metric has no labels (neither parent nor observable), _lock was
never created, causing AttributeError when clear() or other methods
access it.

Fix: initialize self._lock unconditionally before the _is_parent() check.

Fixes prometheus#1140.
@csmarchbanks

Copy link
Copy Markdown
Member

Thanks! This was actually already fixed in #1184 so I am closing it however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_lock not found on metric

2 participants