Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
"""This is a demonstration of sharing file descriptors across processes.
It uses Tornado (need a recent post-2.0 version from github) and the
multiprocessing module (from python 2.6+). To run it, start one copy
of fdserver.py and one or more copies of testserver.py (in different
terminals, or backgrounded, etc). Fetch http://localhost:8000 and
you'll see the requests getting answered by different processes (it's
normal for several requests to go to the same process under light
load, but under heavier load it tends to even out).
@sontek
sontek / gist:3809010
Created October 1, 2012 01:48 — forked from goodwillcoding/gist:3808931
JSON Serializable SQLAlchemy Object
class JsonSerializableMixin(object):
"""
Converts all the properties of the object into a dict for use in json.
You can define the following as your class properties.
_json_eager_load :
list of which child classes need to be eagerly loaded. This applies
to one-to-many relationships defined in SQLAlchemy classes.
_base_blacklist :
@sontek
sontek / button.py
Created May 25, 2012 04:24 — forked from derpston/button.py
Python libusb interface for getting key up/down events from USB HIDs like keyboards.
import sys
import time
import usb
class Button:
def __init__(self, vendor_id, device_id):
"""
Find and open a USB HID device.
"""