suppress exceptions of calling malloc_trim
This commit is contained in:
parent
b504dc04c2
commit
d919190ca1
@ -1,9 +1,9 @@
|
||||
from contextlib import suppress
|
||||
from ctypes import cdll
|
||||
from ctypes.util import find_library
|
||||
from sys import platform
|
||||
|
||||
lib_name = find_library('c')
|
||||
if not lib_name or platform != 'linux':
|
||||
if not lib_name:
|
||||
libc = None
|
||||
else:
|
||||
libc = cdll.LoadLibrary(lib_name)
|
||||
@ -14,4 +14,5 @@ def malloc_trim(pad: int) -> bool:
|
||||
assert pad >= 0, 'pad must be >= 0'
|
||||
if libc is None:
|
||||
return False
|
||||
return libc.malloc_trim(pad) == 1
|
||||
with suppress(Exception):
|
||||
return libc.malloc_trim(pad) == 1
|
||||
|
Loading…
Reference in New Issue
Block a user