Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple support http1.1 keep-alive #7536

Closed
wants to merge 7 commits into from
Closed

simple support http1.1 keep-alive #7536

wants to merge 7 commits into from

Conversation

zii
Copy link

@zii zii commented Nov 10, 2016

Just want to use persistent connection, any idea?

Just want to use persistent connection, any idea?
Copy link
Contributor

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to add tests and release notes too.

@timgraham
Copy link
Member

There's a ticket about it here: https://code.djangoproject.com/ticket/25619
Claude offered #5524, but the selenium tests didn't work. Did you test them with your patch?

@timgraham
Copy link
Member

selenium tests currently fail with AttributeError: 'ServerHandler' object has no attribute 'has_length'. Do you want to try to develop a complete patch with tests, etc?

@zii
Copy link
Author

zii commented Nov 11, 2016

I'm testing with selenium, yes it stuck :(

python runtests.py --selenium chrome

@zii
Copy link
Author

zii commented Nov 11, 2016

I don't know why it stuck in this place, any idea?

GET /test_admin/admin/jsi18n/ HTTP/1.1
Host: localhost:8081
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/53.0.2785.116 Safari/537.36
Accept: */*
Referer: http://localhost:8081/test_admin/admin/admin_views/section/1/change/?_t
o_field=id&_popup=1
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN,zh;q=0.8
Cookie: sessionid=pacii1gfsq4zz8i8nj908swjydoz5c6f; csrftoken=gLjD4Ravyut0xHJqRq
OMPTUVnxfVealPSZOClj2s4UVOaqudLciUHGfElsozsJpS

How odd! It pass the tests after stripping tail newline of response content.
@zii
Copy link
Author

zii commented Nov 11, 2016

How odd! It pass the tests after stripping tail newline of response content.

@zii zii closed this Nov 12, 2016
@zii
Copy link
Author

zii commented Nov 13, 2016

Use tornado or gevent are fine too.

#!/usr/bin/env python
import os
import sys

# http1.1 patch
from django.core.servers import basehttp

def run_tornado(addr, port, wsgi_handler, ipv6=False, threading=False):
    import tornado.wsgi, tornado.httpserver, tornado.ioloop

    container = tornado.wsgi.WSGIContainer(wsgi_handler)
    server = tornado.httpserver.HTTPServer(container)
    server.listen(port=port, address=addr)
    tornado.ioloop.IOLoop.instance().start()

def run_gevent(addr, port, wsgi_handler, ipv6=False, threading=False):
    from gevent import monkey; monkey.patch_all(thread=False)
    from gevent.pywsgi import WSGIServer

    WSGIServer((addr, port), wsgi_handler).serve_forever()

basehttp.run = run_gevent

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "www.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

@claudep
Copy link
Member

claudep commented Feb 10, 2017

I've reopened my PR in #8043. If you think the additions in your patch are adding value or fixing things, please tell us why (and ideally show that by tests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants