Created
December 18, 2017 15:25
-
-
Save smokey42/f8ac17a5e840cfb3ed4774a5d86ff6ed to your computer and use it in GitHub Desktop.
Let a worker process tell the Linux kernel to kill it first.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def _oom_adj_self(): | |
oom_adj = '/proc/%d/oom_adj' % os.getpid() | |
if os.path.exists(oom_adj): | |
with open(oom_adj, 'w') as oom: | |
# OOM killer, please kill this process first. | |
oom.write('15') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment