Skip to content

Instantly share code, notes, and snippets.

@smokey42
Created December 18, 2017 15:25
Show Gist options
  • Save smokey42/f8ac17a5e840cfb3ed4774a5d86ff6ed to your computer and use it in GitHub Desktop.
Save smokey42/f8ac17a5e840cfb3ed4774a5d86ff6ed to your computer and use it in GitHub Desktop.
Let a worker process tell the Linux kernel to kill it first.
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