Skip to content

Instantly share code, notes, and snippets.

View assad2008's full-sized avatar
🏢
working

上官江 assad2008

🏢
working
View GitHub Profile
{
"ignore":"E501",
"format_on_save":true,
}
@assad2008
assad2008 / pool.py
Last active August 29, 2015 14:22 — forked from binux/pool.py
# !/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import time
import Queue
import threading
import traceback
class ExitException(Exception):
@assad2008
assad2008 / pool.py
Last active August 29, 2015 14:06 — forked from binux/pool.py
# !/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import time
import Queue
import threading
import traceback
class ExitException(Exception):
# based on http://uberblo.gs/2011/06/high-performance-url-shortening-with-redis-backed-nginx
# using code from http://stackoverflow.com/questions/3554315/lua-base-converter
# "database scheme"
# database 0: id ~> url
# database 1: id ~> hits
# database 2: id ~> [{referer|user_agent}]
# database 3: id ~> hits (when id is not found)
# database 4: id ~> [{referer|user_agent}] (when id is not found)
# database 5: key "count" storing the number of shortened urls; the id is generated by (this number + 1) converted to base 62