Skip to content

Instantly share code, notes, and snippets.

@vadimg
vadimg / gist:3344325
Created Aug 13, 2012
nginx access log GET request extractor
View gist:3344325
#!/usr/bin/env python
import sys
import re
def iterpings(filename):
for line in open(filename):
m = re.search(r'] GET (.*?) ', line)
if m is not None:
yield m.group(1)
@vadimg
vadimg / timeout.py
Created Jun 9, 2012
python timeout decorator
View timeout.py
import threading
import functools
import logging
def timeout(duration, default=None):
def decorator(func):
class InterruptableThread(threading.Thread):
def __init__(self, args, kwargs):
threading.Thread.__init__(self)
self.args = args