Skip to content

Commit 7236569

Browse files
committed
src/sage/misc/gperftools.py: replace libc shenanigans with cysignals
When the profiler is starting, this module goes to a lot of trouble to do... exactly what cysignals is designed to do. And cysignals does not fail on musl. So let's use cysignals instead?
1 parent 31169fc commit 7236569

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

src/sage/misc/gperftools.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,28 +100,6 @@ def _repr_(self):
100100
"""
101101
return 'Profiler logging to {0}'.format(self.filename())
102102

103-
def _libc(self):
104-
"""
105-
Return libc.
106-
107-
OUTPUT: a ctypes shared library handle
108-
109-
EXAMPLES::
110-
111-
sage: from sage.misc.gperftools import Profiler
112-
sage: Profiler()._libc()
113-
<CDLL '...', handle ... at ...>
114-
"""
115-
global libc
116-
if libc is not None:
117-
return libc
118-
name = find_library('c')
119-
if name:
120-
libc = ctypes.CDLL(name)
121-
return libc
122-
else:
123-
raise ImportError('failed to open libc')
124-
125103
def _libprofiler(self):
126104
"""
127105
Return libprofiler.
@@ -159,7 +137,8 @@ def start(self):
159137
PROFILE: interrupts/evictions/bytes = ...
160138
"""
161139
from signal import SIGPROF, SIG_DFL
162-
self._previous_sigprof_handler = self._libc().signal(SIGPROF, SIG_DFL)
140+
from cysignals.pysignals import setossignal
141+
self._previous_sigprof_handler = setossignal(SIGPROF, SIG_DFL)
163142
profiler = self._libprofiler()
164143
self._t_start = time.time()
165144
rc = profiler.ProfilerStart(str.encode(self.filename()))

0 commit comments

Comments
 (0)