From | To | Expression |
---|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a user land file for testing. | |
# dd if=/dev/urandom of=/tmp/urandom bs=1M count=10 | |
# | |
# urandom-reads.py infile threads | |
# Examples: | |
# time python2.6 urandom-reads.py /tmp/urandom | |
# time python2.6 urandom-reads.py /dev/urandom | |
# | |
# R to generate a plot of the read time distribution at each level of concurrency | |
# rdt = read.csv("output.csv", header=F) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pygments import highlight | |
from pygments.lexers import PythonLexer | |
from pygments.formatters import Terminal256Formatter | |
from pprint import pformat | |
def pprint_color(obj): | |
print highlight(pformat(obj), PythonLexer(), Terminal256Formatter()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- What do Etcd, Consul, and Zookeeper do? | |
- Service Registration: | |
- Host, port number, and sometimes authentication credentials, protocols, versions | |
numbers, and/or environment details. | |
- Service Discovery: | |
- Ability for client application to query the central registry to learn of service location. | |
- Consistent and durable general-purpose K/V store across distributed system. | |
- Some solutions support this better than others. | |
- Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state. | |
- Centralized locking can be based on this K/V store. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import struct | |
import socket | |
state_table = ( | |
"EMPTY SLOT", | |
"ESTABLISHED", | |
"SENT", | |
"RECV", | |
"WAIT1", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/python");</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#coding:utf-8 | |
import sys, os, re | |
import logging | |
from tornado.ioloop import IOLoop | |
from tornado.iostream import IOStream | |
from tornado.netutil import TCPServer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
import tornado | |
from multiprocessing.pool import ThreadPool | |
_workers = ThreadPool(10) | |
class BackgroundMix(tornado.web.RequestHandler): | |
"""将block任务放入线程池中执行 | |
EXAMPLE: | |
# blocking task like querying to MySQL |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
NewerOlder