Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Raise asyncore handle_errors instead of hiding them.

  • Loading branch information...
commit b401f7d3abb13bb8fe59d5cad58a4effd7ea066f 1 parent f3fb245
@mnot authored
Showing with 4 additions and 5 deletions.
  1. +2 −2 setup.py
  2. +2 −3 src/push_tcp.py
View
4 setup.py
@@ -3,12 +3,12 @@
from distutils.core import setup
setup(name='nbhttp',
- version='0.7.2',
+ version='0.7.3',
description='Non-blocking HTTP components',
author='Mark Nottingham',
author_email='mnot@mnot.net',
url='http://github.com/mnot/nbhttp/',
- download_url='http://github.com/mnot/nbhttp/tarball/nbhttp-0.7.2',
+ download_url='http://github.com/mnot/nbhttp/tarball/nbhttp-0.7.3',
packages=['nbhttp'],
package_dir={'nbhttp': 'src'},
scripts=['scripts/proxy.py'],
View
5 src/push_tcp.py
@@ -318,10 +318,9 @@ def writable(self):
def handle_error(self):
"""
- asyncore-specific misc error method. We treat it as if
- the connection was closed.
+ asyncore-specific misc error method.
"""
- self.conn_closed()
+ raise
def create_server(host, port, conn_handler):

1 comment on commit b401f7d

@tssungeng

I modify the server.py like follow for http service.

def test_handler(method, uri, hdrs, res_start, req_pause):
"""
An extremely simple (and limited) server request_handler.
"""
DOCUMENT_ROOT = 'f:/254'
filename = os.path.normpath(DOCUMENT_ROOT + uri)
print filename

try:
    f = open(filename, 'rb')
except IOError, e:
    code = "404"
    phrase = "OK"
    res_hdrs = [('Content-Type', 'text/plain')]
    res_body, res_done = res_start(code, phrase, res_hdrs, dummy)
    res_body('404!')
    res_done(None)
    return dummy, dummy


#mime_type = mimetypes.guess_type(filename)
mimeType,tmp = mimetypes.guess_type(filename)
print mimeType

code = "200"
phrase = "OK"
#res_hdrs = [('Content-Type', 'text/plain')]
res_hdrs = [('Content-Type', mimeType)]

res_body, res_done = res_start(code, phrase, res_hdrs, dummy)
res_body( f.read() )
res_done(None)
f.close()
return dummy, dummy

it is going well, but the performance is not nice. the download speed is low.
How can i advance the download speed?

Please sign in to comment.
Something went wrong with that request. Please try again.