|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /opt/alt/python37/lib/python3.7/site-packages/lvestats/lib/commons/ |
Upload File : |
# coding=utf-8
#
# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2019 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENSE.TXT
from __future__ import absolute_import
import signal
import warnings
import logging
from lvestats.lib.commons import logsetup
def no_sigpipe(func):
def wrapper(*args, **kwargs):
old_pipe_signal = signal.getsignal(signal.SIGPIPE)
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
with warnings.catch_warnings(record=True) as recorded_warnings:
retval = func(*args, **kwargs)
if recorded_warnings and logsetup.FILE_LOG is not None:
log = logging.getLogger("Recorded warnings")
for warning in recorded_warnings:
log.warning(str(warning))
signal.signal(signal.SIGPIPE, old_pipe_signal)
return retval
return wrapper