#NEWLINE# def run( addr , port , wsgi_handler , ipv6 = False , threading = False ) : #NEWLINE# #INDENT# '\n    Function to monkey patch the internal Django command: manage.py runserver\n    ' #NEWLINE# logger . info ( 'Websocket support is enabled' ) #NEWLINE# server_address = ( addr , port ) #NEWLINE# if ( not threading ) : #NEWLINE# #INDENT# raise Exception ( "Django's Websocket server must run with threading enabled" ) #NEWLINE# #UNINDENT# httpd_cls = type ( 'WSGIServer' , ( socketserver . ThreadingMixIn , WSGIServer ) , { #NEWLINE# #INDENT# 'daemon_threads' : True , #NEWLINE# #UNINDENT# } ) #NEWLINE# httpd = httpd_cls ( server_address , WSGIRequestHandler , ipv6 = ipv6 ) #NEWLINE# httpd . set_app ( wsgi_handler ) #NEWLINE# httpd . serve_forever ( )