CheeseAPI 0.4.1__tar.gz → 0.4.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/handle.py +15 -10
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/protocol.py +3 -3
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/text.py +12 -4
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/PKG-INFO +1 -1
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/pyproject.toml +1 -1
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/.gitignore +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/__init__.py +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/app.py +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/cors.py +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/exception.py +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/file.py +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/request.py +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/response.py +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/route.py +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/server.py +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/signal.py +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/websocket.py +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/CheeseAPI/workspace.py +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/LICENSE +0 -0
- {cheeseapi-0.4.1 → cheeseapi-0.4.3}/README.md +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import time, os, inspect, socket, multiprocessing, signal, http, ipaddress
|
|
2
|
-
from typing import TYPE_CHECKING, Dict, Tuple
|
|
2
|
+
from typing import TYPE_CHECKING, Dict, Tuple, List
|
|
3
3
|
|
|
4
4
|
import asyncio, uvloop, setproctitle, websockets
|
|
5
5
|
from CheeseLog import logger
|
|
@@ -120,7 +120,7 @@ class Handle:
|
|
|
120
120
|
sock.listen(self._app.server.backlog)
|
|
121
121
|
sock.set_inheritable(True)
|
|
122
122
|
|
|
123
|
-
processes = []
|
|
123
|
+
processes: List[multiprocessing.Process] = []
|
|
124
124
|
multiprocessing.allow_connection_pickling()
|
|
125
125
|
for i in range(self._app.server.workers - 1):
|
|
126
126
|
process = multiprocessing.Process(target = self.worker_start, args = (sock,), name = self._app._text.workerProcess_title)
|
|
@@ -130,8 +130,21 @@ class Handle:
|
|
|
130
130
|
self.worker_start(sock, True)
|
|
131
131
|
|
|
132
132
|
for process in processes:
|
|
133
|
+
os.kill(process.pid, signal.SIGKILL)
|
|
133
134
|
process.join()
|
|
134
135
|
|
|
136
|
+
for text in self._app._text.server_stopping():
|
|
137
|
+
logger.ending(text[0], text[1])
|
|
138
|
+
|
|
139
|
+
self.server_afterStopping()
|
|
140
|
+
if self._app.signal.server_afterStopping.receivers:
|
|
141
|
+
self._app.signal.server_afterStopping.send()
|
|
142
|
+
|
|
143
|
+
while logger._queue.full():
|
|
144
|
+
time.sleep(self._app.server.intervalTime)
|
|
145
|
+
|
|
146
|
+
os.kill(os.getpid(), signal.SIGKILL)
|
|
147
|
+
|
|
135
148
|
def worker_beforeStarting(self):
|
|
136
149
|
for text in self._app._text.worker_starting():
|
|
137
150
|
logger.debug(text[0], text[1])
|
|
@@ -157,14 +170,6 @@ class Handle:
|
|
|
157
170
|
if self._app.signal.worker_afterStopping.receivers:
|
|
158
171
|
self._app.signal.worker_afterStopping.send()
|
|
159
172
|
|
|
160
|
-
if self._app._managers['server.workers'].value == 0:
|
|
161
|
-
for text in self._app._text.server_stopping():
|
|
162
|
-
logger.ending(text[0], text[1])
|
|
163
|
-
|
|
164
|
-
self.server_afterStopping()
|
|
165
|
-
if self._app.signal.server_afterStopping.receivers:
|
|
166
|
-
self._app.signal.server_afterStopping.send()
|
|
167
|
-
|
|
168
173
|
async def worker_run(self, sock, master: bool):
|
|
169
174
|
from CheeseAPI.app import app
|
|
170
175
|
from CheeseAPI.protocol import HttpProtocol
|
|
@@ -49,9 +49,9 @@ class HttpProtocol(asyncio.Protocol):
|
|
|
49
49
|
self.request.headers['-'.join([t.capitalize() for t in key.decode().split('-')])] = value.decode()
|
|
50
50
|
|
|
51
51
|
def on_headers_complete(self):
|
|
52
|
-
self.request.client = self.request.headers.get('X-Real-Ip',
|
|
53
|
-
self.request.origin = self.request.headers.get('Origin',
|
|
54
|
-
self.request.scheme = self.request.headers.get('X-Forwarded-Proto',
|
|
52
|
+
self.request.client = self.request.headers.get('X-Real-Ip', self.transport.get_extra_info('socket').getpeername()[0])
|
|
53
|
+
self.request.origin = self.request.headers.get('Origin', f'{self.transport.get_extra_info("socket").getsockname()[0]}:{self.transport.get_extra_info("socket").getsockname()[1]}')
|
|
54
|
+
self.request.scheme = self.request.headers.get('X-Forwarded-Proto', 'https' if self.transport.get_extra_info('sslcontext') else 'http')
|
|
55
55
|
|
|
56
56
|
def on_body(self, body: bytes):
|
|
57
57
|
if self.request.body is None:
|
|
@@ -61,10 +61,19 @@ Static: <cyan>{self._app.server.static}</cyan>''' if self._app.workspace.static
|
|
|
61
61
|
return f'Local Modules: {message} {module}', f'Local Modules: {styledMessage} {module}'
|
|
62
62
|
|
|
63
63
|
def loadedLocalModules(self) -> List[Tuple[str, str]]:
|
|
64
|
+
foldernames = self._app.localModules.copy()
|
|
65
|
+
for foldername in self._app.preferred_localModules:
|
|
66
|
+
if foldername in foldernames:
|
|
67
|
+
foldernames.remove(foldername)
|
|
68
|
+
foldernames.insert(0, foldername)
|
|
69
|
+
for foldername in self._app.exclude_localModules:
|
|
70
|
+
if foldername in foldernames:
|
|
71
|
+
foldernames.remove(foldername)
|
|
72
|
+
|
|
64
73
|
return [
|
|
65
74
|
(f'''Local Modules:
|
|
66
|
-
''' + ' | '.join(
|
|
67
|
-
''' + ' | '.join(
|
|
75
|
+
''' + ' | '.join(foldernames), f'''Local Modules:
|
|
76
|
+
''' + ' | '.join(foldernames))
|
|
68
77
|
]
|
|
69
78
|
|
|
70
79
|
def worker_starting(self) -> List[Tuple[str, str]]:
|
|
@@ -138,8 +147,7 @@ Static: <cyan>{self._app.server.static}</cyan>''' if self._app.workspace.static
|
|
|
138
147
|
styledMessage += '<blue>{:.6f}</blue> seconds'.format(timer % 60)
|
|
139
148
|
|
|
140
149
|
return [
|
|
141
|
-
(message, styledMessage)
|
|
142
|
-
(f'The master process {os.getpid()} stopped', f'The master process <blue>{os.getpid()}</blue> stopped')
|
|
150
|
+
(message, styledMessage)
|
|
143
151
|
]
|
|
144
152
|
|
|
145
153
|
@property
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|