Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c578dbf

Browse filesBrowse files
committed
windows support fixes
1 parent ca08a03 commit c578dbf
Copy full SHA for c578dbf

12 files changed

+54
-36
lines changed

‎setup.py

Copy file name to clipboardExpand all lines: setup.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name = 'stackimpact',
5-
version = '1.1.3',
5+
version = '1.1.4',
66
description = 'StackImpact Python Agent',
77
author = 'StackImpact',
88
author_email = 'devops@stackimpact.com',

‎stackimpact/agent.py

Copy file name to clipboardExpand all lines: stackimpact/agent.py
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
class Agent:
2828

29-
AGENT_VERSION = "1.1.3"
29+
AGENT_VERSION = "1.1.4"
3030
SAAS_DASHBOARD_ADDRESS = "https://agent-api.stackimpact.com"
3131

3232
def __init__(self, **kwargs):
@@ -110,7 +110,8 @@ def _signal_handler(signum, frame):
110110

111111
return True
112112

113-
register_signal(signal.SIGUSR2, _signal_handler)
113+
if not runtime_info.OS_WIN:
114+
register_signal(signal.SIGUSR2, _signal_handler)
114115

115116
if self.get_option('auto_destroy') == False:
116117
# destroy agent on exit
@@ -127,10 +128,11 @@ def _exit_handler(*arg):
127128

128129
atexit.register(_exit_handler)
129130

130-
register_signal(signal.SIGQUIT, _exit_handler, once = True)
131-
register_signal(signal.SIGINT, _exit_handler, once = True)
132-
register_signal(signal.SIGTERM, _exit_handler, once = True)
133-
register_signal(signal.SIGHUP, _exit_handler, once = True)
131+
if not runtime_info.OS_WIN:
132+
register_signal(signal.SIGQUIT, _exit_handler, once = True)
133+
register_signal(signal.SIGINT, _exit_handler, once = True)
134+
register_signal(signal.SIGTERM, _exit_handler, once = True)
135+
register_signal(signal.SIGHUP, _exit_handler, once = True)
134136

135137

136138
self.agent_started = True

‎stackimpact/reporters/allocation_reporter.py

Copy file name to clipboardExpand all lines: stackimpact/reporters/allocation_reporter.py
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ def start(self):
3131
if self.agent.get_option('allocation_profiler_disabled'):
3232
return
3333

34-
if not (runtime_info.OS_LINUX or runtime_info.OS_DARWIN) or not min_version(3, 4):
34+
if runtime_info.OS_WIN:
35+
self.agent.log('Memory allocation profiler is not available on Windows.')
36+
return
37+
38+
if not min_version(3, 4):
3539
self.agent.log('Memory allocation profiling is available for Python 3.4 or higher')
3640
return
3741

‎stackimpact/reporters/block_reporter.py

Copy file name to clipboardExpand all lines: stackimpact/reporters/block_reporter.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def setup(self):
3838
if self.agent.get_option('block_profiler_disabled'):
3939
return
4040

41-
if not runtime_info.OS_LINUX and not runtime_info.OS_DARWIN:
42-
self.agent.log('Block profiler is only supported on Linux and OS X.')
41+
if runtime_info.OS_WIN:
42+
self.agent.log('Block profiler is not available on Windows.')
4343
return
4444

4545
sample_time = self.SAMPLING_RATE * 1000

‎stackimpact/reporters/cpu_reporter.py

Copy file name to clipboardExpand all lines: stackimpact/reporters/cpu_reporter.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def setup(self):
3636
if self.agent.get_option('cpu_profiler_disabled'):
3737
return
3838

39-
if not runtime_info.OS_LINUX and not runtime_info.OS_DARWIN:
40-
self.agent.log('CPU profiler is only supported on Linux and OS X.')
39+
if runtime_info.OS_WIN:
40+
self.agent.log('CPU profiler is not available on Windows.')
4141
return
4242

4343
def _sample(signum, signal_frame):

‎stackimpact/reporters/process_reporter.py

Copy file name to clipboardExpand all lines: stackimpact/reporters/process_reporter.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def reset(self):
4444

4545
def report(self):
4646
# CPU
47-
if runtime_info.OS_LINUX or runtime_info.OS_DARWIN:
47+
if not runtime_info.OS_WIN:
4848
cpu_time = read_cpu_time()
4949
if cpu_time != None:
5050
cpu_time_metric = self.report_metric(Metric.TYPE_COUNTER, Metric.CATEGORY_CPU, Metric.NAME_CPU_TIME, Metric.UNIT_NANOSECOND, cpu_time)
@@ -59,7 +59,7 @@ def report(self):
5959

6060

6161
# Memory
62-
if runtime_info.OS_LINUX or runtime_info.OS_DARWIN:
62+
if not runtime_info.OS_WIN:
6363
max_rss = read_max_rss()
6464
if max_rss != None:
6565
self.report_metric(Metric.TYPE_STATE, Metric.CATEGORY_MEMORY, Metric.NAME_MAX_RSS, Metric.UNIT_KILOBYTE, max_rss)

‎tests/agent_test.py

Copy file name to clipboardExpand all lines: tests/agent_test.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
import threading
44

55
import stackimpact
6+
from stackimpact.runtime import runtime_info
67

78

89
# python3 -m unittest discover -s tests -p *_test.py
910

1011
class AgentTestCase(unittest.TestCase):
1112

1213
def test_run_in_main_thread(self):
14+
if runtime_info.OS_WIN:
15+
return
16+
1317
stackimpact._agent = None
1418
agent = stackimpact.start(
1519
dashboard_address = 'http://localhost:5001',

‎tests/reporters/allocation_reporter_test.py

Copy file name to clipboardExpand all lines: tests/reporters/allocation_reporter_test.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class AllocationReporterTestCase(unittest.TestCase):
1212

1313
def test_record_allocation_profile(self):
14-
if not (runtime_info.OS_LINUX or runtime_info.OS_DARWIN) or not min_version(3, 4):
14+
if runtime_info.OS_WIN or not min_version(3, 4):
1515
return
1616

1717
stackimpact._agent = None

‎tests/reporters/block_reporter_test.py

Copy file name to clipboardExpand all lines: tests/reporters/block_reporter_test.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020

2121

2222
class BlockReporterTestCase(unittest.TestCase):
23-
2423
def test_record_block_profile(self):
24+
if runtime_info.OS_WIN:
25+
return
26+
2527
stackimpact._agent = None
2628
agent = stackimpact.start(
2729
dashboard_address = 'http://localhost:5001',

‎tests/reporters/cpu_reporter_test.py

Copy file name to clipboardExpand all lines: tests/reporters/cpu_reporter_test.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class CPUReporterTestCase(unittest.TestCase):
1414

1515
def test_record_profile(self):
16-
if not runtime_info.OS_LINUX and not runtime_info.OS_DARWIN:
16+
if runtime_info.OS_WIN:
1717
return
1818

1919
stackimpact._agent = None

‎tests/reporters/process_reporter_test.py

Copy file name to clipboardExpand all lines: tests/reporters/process_reporter_test.py
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ def test_report(self):
2626

2727
metrics = agent.process_reporter.metrics
2828

29-
self.is_valid(metrics, Metric.TYPE_COUNTER, Metric.CATEGORY_CPU, Metric.NAME_CPU_TIME, 0, float("inf"))
30-
self.is_valid(metrics, Metric.TYPE_STATE, Metric.CATEGORY_CPU, Metric.NAME_CPU_USAGE, 0, float("inf"))
29+
if not runtime_info.OS_WIN:
30+
self.is_valid(metrics, Metric.TYPE_COUNTER, Metric.CATEGORY_CPU, Metric.NAME_CPU_TIME, 0, float("inf"))
31+
self.is_valid(metrics, Metric.TYPE_STATE, Metric.CATEGORY_CPU, Metric.NAME_CPU_USAGE, 0, float("inf"))
32+
33+
if not runtime_info.OS_WIN:
34+
self.is_valid(metrics, Metric.TYPE_STATE, Metric.CATEGORY_MEMORY, Metric.NAME_MAX_RSS, 0, float("inf"))
3135

32-
self.is_valid(metrics, Metric.TYPE_STATE, Metric.CATEGORY_MEMORY, Metric.NAME_MAX_RSS, 0, float("inf"))
3336
if runtime_info.OS_LINUX:
3437
self.is_valid(metrics, Metric.TYPE_STATE, Metric.CATEGORY_MEMORY, Metric.NAME_CURRENT_RSS, 0, float("inf"))
3538
self.is_valid(metrics, Metric.TYPE_STATE, Metric.CATEGORY_MEMORY, Metric.NAME_VM_SIZE, 0, float("inf"))

‎tests/runtime_test.py

Copy file name to clipboardExpand all lines: tests/runtime_test.py
+19-16Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,42 @@
33
import os
44

55
import stackimpact
6-
from stackimpact.runtime import register_signal
6+
from stackimpact.runtime import runtime_info, register_signal
77

88

99
class RuntimeTestCase(unittest.TestCase):
1010

1111
def test_register_signal(self):
12-
result = {'handler': 0}
12+
if runtime_info.OS_WIN:
13+
return
1314

14-
def _handler(signum, frame):
15-
result['handler'] += 1
15+
result = {'handler': 0}
1616

17-
register_signal(signal.SIGUSR1, _handler)
17+
def _handler(signum, frame):
18+
result['handler'] += 1
1819

19-
os.kill(os.getpid(), signal.SIGUSR1)
20-
os.kill(os.getpid(), signal.SIGUSR1)
20+
register_signal(signal.SIGUSR1, _handler)
2121

22-
signal.signal(signal.SIGUSR1, signal.SIG_DFL)
22+
os.kill(os.getpid(), signal.SIGUSR1)
23+
os.kill(os.getpid(), signal.SIGUSR1)
2324

24-
self.assertEqual(result['handler'], 2)
25+
signal.signal(signal.SIGUSR1, signal.SIG_DFL)
26+
27+
self.assertEqual(result['handler'], 2)
2528

2629

2730
'''def test_register_signal_default(self):
28-
result = {'handler': 0}
31+
result = {'handler': 0}
2932
30-
def _handler(signum, frame):
31-
result['handler'] += 1
33+
def _handler(signum, frame):
34+
result['handler'] += 1
3235
33-
register_signal(signal.SIGUSR1, _handler, once = True)
36+
register_signal(signal.SIGUSR1, _handler, once = True)
3437
35-
os.kill(os.getpid(), signal.SIGUSR1)
36-
os.kill(os.getpid(), signal.SIGUSR1)
38+
os.kill(os.getpid(), signal.SIGUSR1)
39+
os.kill(os.getpid(), signal.SIGUSR1)
3740
38-
self.assertEqual(result['handler'], 1)'''
41+
self.assertEqual(result['handler'], 1)'''
3942

4043

4144
if __name__ == '__main__':

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.