CheeseAPI 2.0.7b3__tar.gz → 2.0.7b4__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.7b3 → cheeseapi-2.0.7b4}/CheeseAPI/app.py +2 -1
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/CheeseAPI/scheduler.py +12 -2
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/CheeseAPI/validator.py +7 -5
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/PKG-INFO +1 -1
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/pyproject.toml +1 -1
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/.gitignore +0 -0
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/CheeseAPI/__init__.py +0 -0
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/CheeseAPI/cors.py +0 -0
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/CheeseAPI/file.py +0 -0
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/CheeseAPI/printer.py +0 -0
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/CheeseAPI/request.py +0 -0
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/CheeseAPI/response.py +0 -0
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/CheeseAPI/route.py +0 -0
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/CheeseAPI/signal.py +0 -0
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/CheeseAPI/static.py +0 -0
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/CheeseAPI/websocket.py +0 -0
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/LICENSE +0 -0
- {cheeseapi-2.0.7b3 → cheeseapi-2.0.7b4}/README.md +0 -0
|
@@ -334,7 +334,8 @@ class AppProxy:
|
|
|
334
334
|
async def get_response(self, request: Request) -> Response:
|
|
335
335
|
if inspect.isfunction(request.fn):
|
|
336
336
|
try:
|
|
337
|
-
|
|
337
|
+
signature = inspect.signature(request.fn)
|
|
338
|
+
if 'request' in signature.parameters or any(p.kind == inspect.Parameter.VAR_KEYWORD for p in signature.parameters.values()):
|
|
338
339
|
return await request.fn(request = request)
|
|
339
340
|
else:
|
|
340
341
|
return await request.fn()
|
|
@@ -372,7 +372,9 @@ class SchedulerProxy:
|
|
|
372
372
|
now = time.time()
|
|
373
373
|
|
|
374
374
|
try:
|
|
375
|
-
|
|
375
|
+
signature = inspect.signature(fn)
|
|
376
|
+
has_kwargs = any(p.kind == inspect.Parameter.VAR_KEYWORD for p in signature.parameters.values())
|
|
377
|
+
if 'app' in signature.parameters or has_kwargs:
|
|
376
378
|
fn(*args, app = self.app, **kwargs)
|
|
377
379
|
else:
|
|
378
380
|
fn(*args, **kwargs)
|
|
@@ -386,6 +388,8 @@ class SchedulerProxy:
|
|
|
386
388
|
task._last_run_time = time.time() - now
|
|
387
389
|
task._last_run_timer = datetime.datetime.fromtimestamp(now)
|
|
388
390
|
task._run_num += 1
|
|
391
|
+
if first_run:
|
|
392
|
+
task._queue.get()
|
|
389
393
|
|
|
390
394
|
if static.scheduler_sync_servers:
|
|
391
395
|
sync_server = redis.Redis(connection_pool = static.scheduler_sync_servers[0])
|
|
@@ -423,7 +427,9 @@ class SchedulerProxy:
|
|
|
423
427
|
now = time.time()
|
|
424
428
|
|
|
425
429
|
try:
|
|
426
|
-
|
|
430
|
+
signature = inspect.signature(fn)
|
|
431
|
+
has_kwargs = any(p.kind == inspect.Parameter.VAR_KEYWORD for p in signature.parameters.values())
|
|
432
|
+
if 'app' in signature.parameters or has_kwargs:
|
|
427
433
|
await fn(*args, app = self.app, **kwargs)
|
|
428
434
|
else:
|
|
429
435
|
await fn(*args, **kwargs)
|
|
@@ -437,6 +443,8 @@ class SchedulerProxy:
|
|
|
437
443
|
task._last_run_time = time.time() - now
|
|
438
444
|
task._last_run_timer = datetime.datetime.fromtimestamp(now)
|
|
439
445
|
task._run_num += 1
|
|
446
|
+
if first_run:
|
|
447
|
+
task._queue.get()
|
|
440
448
|
|
|
441
449
|
if static.scheduler_sync_servers:
|
|
442
450
|
sync_server = redis.asyncio.Redis(connection_pool = static.scheduler_sync_servers[1])
|
|
@@ -526,6 +534,7 @@ class SchedulerProxy:
|
|
|
526
534
|
if static.scheduler_sync_servers:
|
|
527
535
|
redis.Redis(connection_pool = static.scheduler_sync_servers[0]).publish('CheeseAPI_scheduler', json.dumps(['remove', key]))
|
|
528
536
|
else:
|
|
537
|
+
_task._queue.put(None)
|
|
529
538
|
self._tasks.pop(key, None)
|
|
530
539
|
if static.scheduler_sync_servers:
|
|
531
540
|
redis.Redis(connection_pool = static.scheduler_sync_servers[0]).hdel('CheeseAPI_scheduler_tasks', key)
|
|
@@ -556,6 +565,7 @@ class SchedulerProxy:
|
|
|
556
565
|
if static.scheduler_sync_servers:
|
|
557
566
|
await redis.asyncio.Redis(connection_pool = static.scheduler_sync_servers[1]).publish('CheeseAPI_scheduler', json.dumps(['remove', key]))
|
|
558
567
|
else:
|
|
568
|
+
_task._queue.put(None)
|
|
559
569
|
self._tasks.pop(key, None)
|
|
560
570
|
if static.scheduler_sync_servers:
|
|
561
571
|
await redis.asyncio.Redis(connection_pool = static.scheduler_sync_servers[1]).hdel('CheeseAPI_scheduler_tasks', key)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import json
|
|
1
|
+
import json, inspect
|
|
2
2
|
from typing import Callable, TYPE_CHECKING
|
|
3
3
|
from functools import wraps
|
|
4
4
|
|
|
@@ -20,10 +20,8 @@ def validator(*, json_model: pydantic.BaseModel | None = None, form_model: pydan
|
|
|
20
20
|
|
|
21
21
|
def wrapper(fn: Callable) -> Callable:
|
|
22
22
|
@wraps(fn)
|
|
23
|
-
async def decorator(*args, **kwargs):
|
|
23
|
+
async def decorator(*args, request: 'Request', **kwargs):
|
|
24
24
|
try:
|
|
25
|
-
request: 'Request' = kwargs.get('request', None)
|
|
26
|
-
|
|
27
25
|
json_data = None
|
|
28
26
|
if json_model is not None:
|
|
29
27
|
json_data = json_model.model_validate(request.json or {}, by_alias = True)
|
|
@@ -59,6 +57,10 @@ def validator(*, json_model: pydantic.BaseModel | None = None, form_model: pydan
|
|
|
59
57
|
else:
|
|
60
58
|
return Response(json.loads(e.json()), 400)
|
|
61
59
|
|
|
62
|
-
|
|
60
|
+
signature = inspect.signature(fn)
|
|
61
|
+
if 'request' in signature.parameters or any(p.kind == inspect.Parameter.VAR_KEYWORD for p in signature.parameters.values()):
|
|
62
|
+
return await fn(*args, request = request, **kwargs)
|
|
63
|
+
else:
|
|
64
|
+
return await fn(*args, **kwargs)
|
|
63
65
|
return decorator
|
|
64
66
|
return wrapper
|
|
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
|