Browse Source

deal with gevent 1.0 upgrade

https://github.com/surfly/gevent/issues/438
raylu 11 years ago
parent
commit
61f16af69c
1 changed files with 4 additions and 6 deletions
  1. 4 6
      api/server.py

+ 4 - 6
api/server.py

@@ -1,7 +1,5 @@
 #!/usr/bin/env python
 
-import warnings
-warnings.filterwarnings('ignore', 'libevent')
 import gevent.monkey
 gevent.monkey.patch_all(thread=False)
 
@@ -55,7 +53,7 @@ ERROR_HEADERS = BASE_HEADERS + [('Content-type', 'text/plain')]
 def application(environ, start_response):
 	try:
 		if environ['REQUEST_METHOD'] == 'OPTIONS':
-			start_response('200 OK', DEFAULT_HEADERS)
+			start_response('200 OK', copy.copy(DEFAULT_HEADERS))
 			return []
 		split = environ['PATH_INFO'][1:].split('/')
 		qs = environ['QUERY_STRING']
@@ -71,7 +69,7 @@ def application(environ, start_response):
 			handler = handlers.get(split[2])
 			if handler:
 				body = json.dumps(handler(split, query, environ))
-				start_response('200 OK', DEFAULT_HEADERS)
+				start_response('200 OK', copy.copy(DEFAULT_HEADERS))
 				return [body]
 			else:
 				print 'no handler for', split
@@ -80,11 +78,11 @@ def application(environ, start_response):
 		raise HTTPException(404, 'unhandled path: ' + environ['PATH_INFO'])
 	except HTTPException as e:
 		response = '%d %s' % (e.code, httplib.responses[e.code])
-		start_response(response, ERROR_HEADERS)
+		start_response(response, copy.copy(ERROR_HEADERS))
 		return [e.body]
 	except:
 		traceback.print_exc()
-		start_response('500 Internal Server Error', ERROR_HEADERS)
+		start_response('500 Internal Server Error', copy.copy(ERROR_HEADERS))
 		return ['ruh roh']
 
 def get_raw(split, query, environ):