Python 提供了两个基本的 socket 模块:
Socket
它提供了标准的BSD Socket API。SocketServer
它提供了服务器重心,可以简化网络服务器的开发。
下面讲解下 Socket模块功能。
import gevent | |
from gevent.monkey import patch_all | |
patch_all() | |
import requests | |
import json | |
s = requests.Session() | |
def make_request(s, d): |
""" | |
Dependencies: | |
pip install tabulate simplejson ujson yajl msgpack | |
""" | |
from timeit import timeit | |
from tabulate import tabulate | |
setup = '''d = { | |
'words': """ |
from django.core.exceptions import MiddlewareNotUsed | |
from django.conf import settings | |
import cProfile | |
import pstats | |
import marshal | |
from cStringIO import StringIO | |
class ProfileMiddleware(object): | |
def __init__(self): | |
if not settings.DEBUG: |