本文整理汇总了Python中resource.RLIMIT_CORE属性的典型用法代码示例。如果您正苦于以下问题:Python resource.RLIMIT_CORE属性的具体用法?Python resource.RLIMIT_CORE怎么用?Python resource.RLIMIT_CORE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类resource
的用法示例。
在下文中一共展示了resource.RLIMIT_CORE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prevent_core_dump
# 需要导入模块: import resource [as 别名]
# 或者: from resource import RLIMIT_CORE [as 别名]
def prevent_core_dump():
""" Prevent this process from generating a core dump.
Sets the soft and hard limits for core dump size to zero. On
Unix, this prevents the process from creating core dump
altogether.
"""
core_resource = resource.RLIMIT_CORE
try:
# Ensure the resource limit exists on this platform, by requesting
# its current value
core_limit_prev = resource.getrlimit(core_resource)
except ValueError, exc:
error = DaemonOSEnvironmentError(
"System does not support RLIMIT_CORE resource limit (%(exc)s)"
% vars())
raise error
# Set hard and soft limits to zero, i.e. no core dump at all
示例2: prevent_core_dump
# 需要导入模块: import resource [as 别名]
# 或者: from resource import RLIMIT_CORE [as 别名]
def prevent_core_dump():
""" Prevent this process from generating a core dump.
Sets the soft and hard limits for core dump size to zero. On
Unix, this prevents the process from creating core dump
altogether.
"""
core_resource = resource.RLIMIT_CORE
try:
# Ensure the resource limit exists on this platform, by requesting
# its current value
resource.getrlimit(core_resource)
except ValueError as exc:
error = DaemonOSEnvironmentError(
"System does not support RLIMIT_CORE resource limit (%s)" % exc)
raise error
# Set hard and soft limits to zero, i.e. no core dump at all
core_limit = (0, 0)
resource.setrlimit(core_resource, core_limit)
示例3: prevent_core_dump
# 需要导入模块: import resource [as 别名]
# 或者: from resource import RLIMIT_CORE [as 别名]
def prevent_core_dump():
"""Prevent this process from generating a core dump."""
core_resource = resource.RLIMIT_CORE
try:
resource.getrlimit(core_resource)
except ValueError as ex:
raise DaemonError(
'Unable to limit core dump size: '
'system does not support RLIMIT_CORE resource limit') from ex
# Set hard & soft limits to 0, i.e. no core dump at all
resource.setrlimit(core_resource, (0, 0))
示例4: test_core_size
# 需要导入模块: import resource [as 别名]
# 或者: from resource import RLIMIT_CORE [as 别名]
def test_core_size(self):
size = self.soft_limit(resource.RLIMIT_CORE, 1, 1024)
prlimit = processutils.ProcessLimits(core_file_size=size)
self.check_limit(prlimit, 'RLIMIT_CORE', prlimit.core_file_size)
示例5: core_ulimit
# 需要导入模块: import resource [as 别名]
# 或者: from resource import RLIMIT_CORE [as 别名]
def core_ulimit():
import resource
(x, y) = resource.getrlimit(resource.RLIMIT_CORE)
resource.setrlimit(
resource.RLIMIT_CORE,
(resource.RLIM_INFINITY, resource.RLIM_INFINITY)
)
yield
resource.setrlimit(resource.RLIMIT_CORE, (x, y))