CheeseAPI 2.0.6b1__tar.gz → 2.0.6b3__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.6b1 → cheeseapi-2.0.6b3}/CheeseAPI/scheduler.py +9 -15
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/PKG-INFO +1 -1
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/pyproject.toml +1 -1
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/.gitignore +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/CheeseAPI/__init__.py +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/CheeseAPI/app.py +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/CheeseAPI/cors.py +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/CheeseAPI/file.py +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/CheeseAPI/printer.py +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/CheeseAPI/request.py +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/CheeseAPI/response.py +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/CheeseAPI/route.py +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/CheeseAPI/signal.py +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/CheeseAPI/static.py +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/CheeseAPI/validator.py +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/CheeseAPI/websocket.py +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/LICENSE +0 -0
- {cheeseapi-2.0.6b1 → cheeseapi-2.0.6b3}/README.md +0 -0
|
@@ -16,10 +16,10 @@ class Task:
|
|
|
16
16
|
for key, value in data.items():
|
|
17
17
|
if key == '_queue':
|
|
18
18
|
if value:
|
|
19
|
-
value = multiprocessing.Queue()
|
|
19
|
+
value = multiprocessing.get_context('spawn').Queue()
|
|
20
20
|
value.put(None)
|
|
21
21
|
else:
|
|
22
|
-
value = multiprocessing.Queue()
|
|
22
|
+
value = multiprocessing.get_context('spawn').Queue()
|
|
23
23
|
elif key == 'first_run_timer':
|
|
24
24
|
value = datetime.datetime.fromtimestamp(value) if value else None
|
|
25
25
|
elif key == '_last_run_timer':
|
|
@@ -67,7 +67,7 @@ class Task:
|
|
|
67
67
|
self._last_run_time: float | None = None
|
|
68
68
|
self._run_num: int = 0
|
|
69
69
|
self._handler: threading.Thread | multiprocessing.Process | asyncio.Task | None = None
|
|
70
|
-
self._queue = multiprocessing.Queue()
|
|
70
|
+
self._queue = multiprocessing.get_context('spawn').Queue()
|
|
71
71
|
|
|
72
72
|
def __getstate__(self) -> tuple[None, dict[str, any]]:
|
|
73
73
|
state = {
|
|
@@ -242,6 +242,7 @@ class SchedulerProxy:
|
|
|
242
242
|
|
|
243
243
|
def __setstate__(self, state):
|
|
244
244
|
self.app = state[1]['app']
|
|
245
|
+
self._tasks = {}
|
|
245
246
|
|
|
246
247
|
def init(self, app = None):
|
|
247
248
|
if not app:
|
|
@@ -357,7 +358,6 @@ class SchedulerProxy:
|
|
|
357
358
|
return
|
|
358
359
|
|
|
359
360
|
queue.get()
|
|
360
|
-
task._queue.get()
|
|
361
361
|
first_run = True
|
|
362
362
|
|
|
363
363
|
if task.first_run_timer:
|
|
@@ -383,8 +383,6 @@ class SchedulerProxy:
|
|
|
383
383
|
task = self.get_task(key)
|
|
384
384
|
|
|
385
385
|
if task:
|
|
386
|
-
if first_run:
|
|
387
|
-
task._queue.get()
|
|
388
386
|
task._last_run_time = time.time() - now
|
|
389
387
|
task._last_run_timer = datetime.datetime.fromtimestamp(now)
|
|
390
388
|
task._run_num += 1
|
|
@@ -402,8 +400,6 @@ class SchedulerProxy:
|
|
|
402
400
|
except (KeyboardInterrupt, SystemExit):
|
|
403
401
|
...
|
|
404
402
|
|
|
405
|
-
queue.put(None)
|
|
406
|
-
|
|
407
403
|
if static.scheduler_sync_servers and task:
|
|
408
404
|
redis.Redis(connection_pool = static.scheduler_sync_servers[0]).hpersist('CheeseAPI_scheduler_tasks', key)
|
|
409
405
|
|
|
@@ -413,7 +409,6 @@ class SchedulerProxy:
|
|
|
413
409
|
return
|
|
414
410
|
|
|
415
411
|
queue.get()
|
|
416
|
-
task._queue.get()
|
|
417
412
|
first_run = True
|
|
418
413
|
|
|
419
414
|
if task.first_run_timer:
|
|
@@ -439,8 +434,6 @@ class SchedulerProxy:
|
|
|
439
434
|
task = await self.async_get_task(key)
|
|
440
435
|
|
|
441
436
|
if task:
|
|
442
|
-
if first_run:
|
|
443
|
-
task._queue.get()
|
|
444
437
|
task._last_run_time = time.time() - now
|
|
445
438
|
task._last_run_timer = datetime.datetime.fromtimestamp(now)
|
|
446
439
|
task._run_num += 1
|
|
@@ -470,7 +463,8 @@ class SchedulerProxy:
|
|
|
470
463
|
elif task.run_type == 'PROCESS' and isinstance(task._handler, multiprocessing.Process):
|
|
471
464
|
task._handler.join()
|
|
472
465
|
self._tasks.pop(task.key, None)
|
|
473
|
-
|
|
466
|
+
if static.scheduler_sync_servers:
|
|
467
|
+
redis.Redis(connection_pool = static.scheduler_sync_servers[0]).hdel('CheeseAPI_scheduler_tasks', task.key)
|
|
474
468
|
|
|
475
469
|
def start(self, key: str):
|
|
476
470
|
task = self.get_task(key)
|
|
@@ -504,7 +498,7 @@ class SchedulerProxy:
|
|
|
504
498
|
if not task and static.scheduler_sync_servers:
|
|
505
499
|
await redis.asyncio.Redis(connection_pool = static.scheduler_sync_servers[1]).publish('CheeseAPI_scheduler', json.dumps(['start', key]))
|
|
506
500
|
else:
|
|
507
|
-
task._handler = asyncio.create_task(self.async_task_processing(task, *task.args, **task.kwargs))
|
|
501
|
+
task._handler = asyncio.create_task(self.async_task_processing(key, task._queue, task.fn, *task.args, **task.kwargs))
|
|
508
502
|
|
|
509
503
|
def stop(self, key: str):
|
|
510
504
|
task = self.get_task(key)
|
|
@@ -524,7 +518,7 @@ class SchedulerProxy:
|
|
|
524
518
|
|
|
525
519
|
def remove(self, key: str):
|
|
526
520
|
task = self.get_task(key)
|
|
527
|
-
if not task
|
|
521
|
+
if not task:
|
|
528
522
|
return
|
|
529
523
|
|
|
530
524
|
_task = self._tasks.get(key)
|
|
@@ -554,7 +548,7 @@ class SchedulerProxy:
|
|
|
554
548
|
|
|
555
549
|
async def async_remove(self, key: str):
|
|
556
550
|
task = await self.async_get_task(key)
|
|
557
|
-
if not task
|
|
551
|
+
if not task:
|
|
558
552
|
return
|
|
559
553
|
|
|
560
554
|
_task = self._tasks.get(key)
|
|
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
|