File: test__issue58.py

package info (click to toggle)
python-gevent 0.13.6-1%2Bnmu3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,324 kB
  • sloc: python: 13,296; makefile: 95; ansic: 37
file content (22 lines) | stat: -rw-r--r-- 512 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import sys
import gevent
from gevent import wsgi
from gevent import socket


def error(env, start_response):
    try:
        raise ValueError('hello')
    except Exception:
        exc = sys.exc_info()
        raise

server = wsgi.WSGIServer(('', 0), error)
server.start()
conn = socket.create_connection(('127.0.0.1', server.server_port))
conn.sendall('GET / HTTP/1.1\r\nConnection: close\r\n\r\n')
timeout = gevent.Timeout.start_new(0.1)
try:
    conn.makefile(bufsize=1).read()
finally:
    timeout.cancel()