mirror of
https://github.com/django/daphne.git
synced 2025-08-02 17:50:09 +03:00
os.system
This commit is contained in:
parent
63e51dbf62
commit
cd9b9a4f98
|
@ -1,6 +1,6 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
__version__ = "3.0.10"
|
__version__ = "3.0.12"
|
||||||
|
|
||||||
|
|
||||||
# Windows on Python 3.8+ uses ProactorEventLoop, which is not compatible with
|
# Windows on Python 3.8+ uses ProactorEventLoop, which is not compatible with
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -14,7 +15,6 @@ from .utils import parse_x_forwarded_for
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class WebRequest(http.Request):
|
class WebRequest(http.Request):
|
||||||
"""
|
"""
|
||||||
Request that either hands off information to channels, or offloads
|
Request that either hands off information to channels, or offloads
|
||||||
|
@ -146,11 +146,6 @@ class WebRequest(http.Request):
|
||||||
|
|
||||||
# Boring old HTTP.
|
# Boring old HTTP.
|
||||||
else:
|
else:
|
||||||
# Count completed Request and check against Max Requests
|
|
||||||
self.server._complete_requests_counted += 1
|
|
||||||
if self.server._complete_requests_counted > self.server.max_requests:
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
# Sanitize and decode headers, potentially extracting root path
|
# Sanitize and decode headers, potentially extracting root path
|
||||||
self.clean_headers = []
|
self.clean_headers = []
|
||||||
self.root_path = self.server.root_path
|
self.root_path = self.server.root_path
|
||||||
|
@ -204,6 +199,14 @@ class WebRequest(http.Request):
|
||||||
if not more_body:
|
if not more_body:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# Count completed requests and check against Max
|
||||||
|
self.server._complete_requests_counted += 1
|
||||||
|
if self.server._complete_requests_counted > self.server.max_requests:
|
||||||
|
logger.info('Max requests completed. Shutting down daphne...')
|
||||||
|
bash_command = 'kill $(ps -a | grep daphne | cut -f 1 -d " " | head -n 1)'
|
||||||
|
os.system(bash_command)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
self.basic_error(
|
self.basic_error(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user