os.system

This commit is contained in:
Adam La Morre 2022-02-06 18:03:16 -08:00
parent 63e51dbf62
commit cd9b9a4f98
3 changed files with 15 additions and 7 deletions

View File

@ -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

View File

@ -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(

5
notes.txt Normal file
View File

@ -0,0 +1,5 @@
Build: python setup.py sdist bdist_wheel
Test Upload: twine upload --repository-url https://test.pypi.org/legacy/ dist/*
Prod Upload: twine upload dist/*
Test Install: pip install -i https://test.pypi.org/simple/ adam-daphne==3.0.9