10000 Disable gcCollector for pypy (#380) · benxiaolang-hacker/client_python@f820190 · GitHub
[go: up one dir, main page]

Skip to content

Commit f820190

Browse files
Krukovbrian-brazil
authored andcommitted
Disable gcCollector for pypy (prometheus#380)
Signed-off-by: Krukov Dima <glebov.ru@gmail.com>
1 parent 3cb4c92 commit f820190

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ matrix:
2323
env: TOXENV=py36-nooptionals
2424
- python: "pypy"
2525
env: TOXENV=pypy
26+
- python: "pypy3"
27+
env: TOXENV=pypy3
2628

2729
install:
2830
- pip install tox

prometheus_client/gc_collector.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import unicode_literals
44

55
import gc
6+
import platform
67

78
from .metrics_core import CounterMetricFamily
89
from .registry import REGISTRY
@@ -12,7 +13,7 @@ class GCCollector(object):
1213
"""Collector for Garbage collection statistics."""
1314

1415
def __init__(self, registry=REGISTRY):
15-
if not hasattr(gc, 'get_stats'):
16+
if not hasattr(gc, 'get_stats') or platform.python_implementation() != 'CPython':
1617
return
1718
registry.register(self)
1819

tests/test_gc_collector.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import gc
44
import sys
5+
import platform
56

67
if sys.version_info < (2, 7):
78
# We need the skip decorators from unittest2 on Python 2.6.
@@ -11,8 +12,10 @@
1112

1213
from prometheus_client import CollectorRegistry, GCCollector
1314

15+
SKIP = sys.version_info < (3, 4) or platform.python_implementation() != "CPython"
1416

15-
@unittest.skipIf(sys.version_info < (3, 4), "Test requires Python 3.4 +")
17+
18+
@unittest.skipIf(SKIP, "Test requires CPython 3.4 +")
1619
class TestGCCollector(unittest.TestCase):
1720
def setUp(self):
1821
gc.disable()

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = coverage-clean,py26,py27,py34,py35,py36,pypy,{py27,py36}-nooptionals,coverage-report,flake8
2+
envlist = coverage-clean,py26,py27,py34,py35,py36,pypy,pypy3,{py27,py36}-nooptionals,coverage-report,flake8
33

44

55
[base]
@@ -29,7 +29,7 @@ deps =
2929
[testenv]
3030
deps =
3131
{[base]deps}
32-
{py27,py34,py35,py36,pypy}: twisted
32+
{py27,py34,py35,py36,pypy,pypy3}: twisted
3333
commands = coverage run --parallel -m pytest {posargs}
3434

3535

0 commit comments

Comments
 (0)
0