CheeseAPI 2.0.6__tar.gz → 2.0.6b1__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-2.0.6 → cheeseapi-2.0.6b1}/CheeseAPI/app.py +4 -1
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/CheeseAPI/scheduler.py +13 -6
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/CheeseAPI/websocket.py +1 -1
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/PKG-INFO +1 -1
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/pyproject.toml +1 -1
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/.gitignore +0 -0
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/CheeseAPI/__init__.py +0 -0
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/CheeseAPI/cors.py +0 -0
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/CheeseAPI/file.py +0 -0
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/CheeseAPI/printer.py +0 -0
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/CheeseAPI/request.py +0 -0
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/CheeseAPI/response.py +0 -0
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/CheeseAPI/route.py +0 -0
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/CheeseAPI/signal.py +0 -0
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/CheeseAPI/static.py +0 -0
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/CheeseAPI/validator.py +0 -0
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/LICENSE +0 -0
- {cheeseapi-2.0.6 → cheeseapi-2.0.6b1}/README.md +0 -0
|
@@ -334,7 +334,10 @@ class AppProxy:
|
|
|
334
334
|
async def get_response(self, request: Request) -> Response:
|
|
335
335
|
if inspect.isfunction(request.fn):
|
|
336
336
|
try:
|
|
337
|
-
|
|
337
|
+
if 'request' in inspect.signature(request.fn).parameters:
|
|
338
|
+
return await request.fn(request = request)
|
|
339
|
+
else:
|
|
340
|
+
return await request.fn()
|
|
338
341
|
except Exception as e:
|
|
339
342
|
self.app.printer.fn_error(e, request)
|
|
340
343
|
return Response(status = 500)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import inspect
|
|
1
2
|
import datetime, uuid, threading, multiprocessing, asyncio, time, json
|
|
2
3
|
from typing import Callable, Literal, TYPE_CHECKING
|
|
3
4
|
|
|
@@ -39,7 +40,7 @@ class Task:
|
|
|
39
40
|
- expected_run_num: 预期执行次数,若未设置则无限次执行
|
|
40
41
|
- key: 默认为随机 uuid
|
|
41
42
|
- run_type: 任务执行方式,可选线程、协程、进程
|
|
42
|
-
-
|
|
43
|
+
- kwargs: 自动包含 `app: CheeseAPI`,如果不提供 app 参数位置,则不会传入
|
|
43
44
|
- auto_remove: 任务完成期望次数后是否自动移除
|
|
44
45
|
- timeout: 当 app.sync_server_url 存在时,任务超过多少秒没有执行完毕则认为执行失败,在 sync_server 中会视为任务删除,None 默认为 interval_time * 2 的值;恢复执行后会在 sync_server 上自动恢复
|
|
45
46
|
'''
|
|
@@ -55,8 +56,8 @@ class Task:
|
|
|
55
56
|
self.run_type: Literal['THREAD', 'PROCESS', 'ASYNC'] = run_type
|
|
56
57
|
''' 任务执行方式,可选线程、协程、进程 '''
|
|
57
58
|
self.args: tuple = args
|
|
58
|
-
''' 默认首位是 `app: CheeseAPI` '''
|
|
59
59
|
self.kwargs: dict = kwargs
|
|
60
|
+
''' 自动包含 `app: CheeseAPI`,如果不提供 app 参数位置,则不会传入 '''
|
|
60
61
|
self.auto_remove: bool = auto_remove
|
|
61
62
|
''' 任务完成期望次数后是否自动移除 '''
|
|
62
63
|
self.timeout: float = timeout if timeout is not None else interval_time * 2
|
|
@@ -146,7 +147,7 @@ class Scheduler:
|
|
|
146
147
|
- expected_run_num: 预期执行次数,若未设置则无限次执行
|
|
147
148
|
- key: 默认为 uuid
|
|
148
149
|
- run_type: 任务执行方式,可选线程、进程
|
|
149
|
-
-
|
|
150
|
+
- kwargs: 自动包含 `app: CheeseAPI`,如果不提供 app 参数位置,则不会传入
|
|
150
151
|
- auto_remove: 任务完成期望次数后是否自动移除
|
|
151
152
|
- timeout: 当 app.sync_server_url 存在时,任务超过多少秒没有执行完毕则认为执行失败,在 sync_server 中会视为任务删除,None 默认为 interval_time * 2 的值;恢复执行后会在 sync_server 上自动恢复
|
|
152
153
|
'''
|
|
@@ -164,7 +165,7 @@ class Scheduler:
|
|
|
164
165
|
- first_run_timer: 首次执行时间,若值小于当前时间则立刻执行
|
|
165
166
|
- expected_run_num: 预期执行次数,若未设置则无限次执行
|
|
166
167
|
- key: 默认为 uuid
|
|
167
|
-
-
|
|
168
|
+
- kwargs: 自动包含 `app: CheeseAPI`,如果不提供 app 参数位置,则不会传入
|
|
168
169
|
- auto_remove: 任务完成期望次数后是否自动移除
|
|
169
170
|
- timeout: 当 app.sync_server_url 存在时,任务超过多少秒没有执行完毕则认为执行失败,在 sync_server 中会视为任务删除,None 默认为 interval_time * 2 的值;恢复执行后会在 sync_server 上自动恢复
|
|
170
171
|
'''
|
|
@@ -371,7 +372,10 @@ class SchedulerProxy:
|
|
|
371
372
|
now = time.time()
|
|
372
373
|
|
|
373
374
|
try:
|
|
374
|
-
|
|
375
|
+
if 'app' in inspect.signature(fn).parameters:
|
|
376
|
+
fn(*args, app = self.app, **kwargs)
|
|
377
|
+
else:
|
|
378
|
+
fn(*args, **kwargs)
|
|
375
379
|
except Exception as e:
|
|
376
380
|
self.app.printer.scheduler_error(e, task)
|
|
377
381
|
|
|
@@ -424,7 +428,10 @@ class SchedulerProxy:
|
|
|
424
428
|
now = time.time()
|
|
425
429
|
|
|
426
430
|
try:
|
|
427
|
-
|
|
431
|
+
if 'app' in inspect.signature(fn).parameters:
|
|
432
|
+
await fn(*args, app = self.app, **kwargs)
|
|
433
|
+
else:
|
|
434
|
+
await fn(*args, **kwargs)
|
|
428
435
|
except Exception as e:
|
|
429
436
|
self.app.printer.scheduler_error(e, task)
|
|
430
437
|
|
|
@@ -210,7 +210,7 @@ class WebsocketProxy:
|
|
|
210
210
|
await self.message()
|
|
211
211
|
await self.disconnect()
|
|
212
212
|
except Exception as e:
|
|
213
|
-
await self.app.printer.websocket_error(self.websocket
|
|
213
|
+
await self.app.printer.websocket_error(e, self.websocket)
|
|
214
214
|
|
|
215
215
|
async def get_response(self) -> Response:
|
|
216
216
|
headers = {
|
|
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
|