~justin-fathomdb/nova/justinsb-openstack-api-volumes

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/benchmarks/tpserver_nt.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Non-twisted throughput server."""
 
2
 
 
3
import socket, signal, sys
 
4
 
 
5
def signalhandler(*args):
 
6
    print "alarm!"
 
7
    sys.stdout.flush()
 
8
 
 
9
signal.signal(signal.SIGALRM, signalhandler)
 
10
 
 
11
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 
12
s.bind(('', 8001))
 
13
s.listen(1)
 
14
while 1:
 
15
    c, (h, p) = s.accept()
 
16
    c.settimeout(30)
 
17
    signal.alarm(5)
 
18
    while 1:
 
19
        d = c.recv(16384)
 
20
        if not d:
 
21
            break
 
22
    c.close()