Skip to content

Instantly share code, notes, and snippets.

View altaurog's full-sized avatar

Aryeh Leib Taurog altaurog

View GitHub Profile
@altaurog
altaurog / pnid.py
Created August 12, 2015 20:07
Get PID of n'th parent (linux only)
import os
"""
Get PID of n'th parent
This works in linux only
"""
def pnid(n=1, pid=os.getpid()):
for i in range(n):
try:
procfile = open("/proc/%s/status" % pid)
@altaurog
altaurog / droprace.py
Created July 10, 2014 05:52
PostgreSQL drop/rename race condition
import logging
import os
import sys
import time
import threading
import psycopg2
"""
This script demonstrates the following race condition under PostgreSQL:
One connection, in transaction, drops table "mytable," then renames