Skip to content

Commit c578dbf

Browse files
committed
windows support fixes
1 parent ca08a03 commit c578dbf

File tree

12 files changed

+54
-36
lines changed

12 files changed

+54
-36
lines changed

setup.py

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

0 commit comments

Comments
 (0)