mirror of
https://github.com/django/daphne.git
synced 2025-07-31 17:29:44 +03:00
os.system
This commit is contained in:
parent
63e51dbf62
commit
cd9b9a4f98
|
@ -1,6 +1,6 @@
|
|||
import sys
|
||||
|
||||
__version__ = "3.0.10"
|
||||
__version__ = "3.0.12"
|
||||
|
||||
|
||||
# Windows on Python 3.8+ uses ProactorEventLoop, which is not compatible with
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
|
@ -14,7 +15,6 @@ from .utils import parse_x_forwarded_for
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class WebRequest(http.Request):
|
||||
"""
|
||||
Request that either hands off information to channels, or offloads
|
||||
|
@ -146,11 +146,6 @@ class WebRequest(http.Request):
|
|||
|
||||
# Boring old HTTP.
|
||||
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
|
||||
self.clean_headers = []
|
||||
self.root_path = self.server.root_path
|
||||
|
@ -204,6 +199,14 @@ class WebRequest(http.Request):
|
|||
if not more_body:
|
||||
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:
|
||||
logger.error(traceback.format_exc())
|
||||
self.basic_error(
|
||||
|
|
Loading…
Reference in New Issue
Block a user