8000 make global _PAGESIZE variable a class member by stefanotorresi · Pull Request #522 · prometheus/client_python · GitHub
[go: up one dir, main page]

Skip to content

make global _PAGESIZE variable a class member #522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

stefanotorresi
Copy link
Contributor

fixes #519

@@ -31,6 +23,12 @@ def __init__(self, namespace='', pid=lambda: 'self', proc='/proc', registry=REGI
except (ValueError, TypeError, AttributeError, OSError):
pass

try:
self._pagesize = resource.getpagesize()
except ImportError:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right, the import is elsewhere now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh you're right. For some reason, I thought the error was triggered by getpagesize().
I'll move the import back into the try block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or do you prefer it still at the top, leaving the previous _PAGESIZE global, and rather just initialize a local variable from that?

Copy link
Contributor Author
@stefanotorresi stefanotorresi Mar 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I might actually prefer that, much smaller diff and the import in the middle of a class init is a bit weird 😛

@stefanotorresi stefanotorresi force-pushed the fix/519-pagesize-mock branch from e3f35d3 to 81dca0f Compare March 2, 2020 14:39
move the import where it belongs

move the import back to the top of the file and rather initialize the local variable from the global

Signed-off-by: Stefano Torresi <stefano@torresi.io>
@stefanotorresi stefanotorresi force-pushed the fix/519-pagesize-mock branch from 81dca0f to 0372880 Compare March 2, 2020 14:53
@brian-brazil brian-brazil merged commit 2d85f4a into prometheus:master Mar 2, 2020
@brian-brazil
Copy link
Contributor

Thanks!

@stefanotorresi stefanotorresi deleted the fix/519-pagesize-mock branch March 2, 2020 18:26
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.

TestProcessCollector failing on ppc64le architecture
2 participants
0