Skip to content

Instantly share code, notes, and snippets.

@marekbrzoska
marekbrzoska / Defering Django fields
Created Jul 17, 2012
A try of library for defering field in Django. This version is prepared with relationship (FK, ManyToMany etc) in mind. Inpired by https://github.com/mirumee/satchless/blob/master/satchless/util/models.py
View Defering Django fields
from django.db import models
class DeferedField(object):
def __init__(self, cls, **kwargs):
'''When defining defered field, we declare it's type and properties'''
self.cls = cls
self.kwargs = kwargs
def construct(self, model_alias, **kwargs):
View gist:6146639
#Refer: http://www.linuxfoundation.org/collaborate/workgroups/networking/netem#Delaying_only_some_traffic
#Refer: http://www.bomisofmab.com/blog/?p=100
#Refer: http://drija.com/linux/41983/simulating-a-low-bandwidth-high-latency-network-connection-on-linux/
#Setup the rate control and delay
sudo tc qdisc add dev lo root handle 1: htb default 12
sudo tc class add dev lo parent 1:1 classid 1:12 htb rate 56kbps ceil 128kbps
sudo tc qdisc add dev lo parent 1:12 netem delay 200ms
#Remove the rate control/delay
sudo tc qdisc del dev lo root