CheeseAPI 2.0.5b3__tar.gz → 2.0.5b4__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.
@@ -94,7 +94,7 @@ class Task:
94
94
 
95
95
  async def async_start(self):
96
96
  if not self._handler:
97
- self._handler = asyncio.create_task(self._scheduler_proxy.async_task_processing(self.key, self.fn, *self.args, **self.kwargs))
97
+ self._handler = asyncio.create_task(self._scheduler_proxy.async_task_processing(self.key, self._queue, self.fn, *self.args, **self.kwargs))
98
98
 
99
99
  @property
100
100
  def key(self) -> str:
@@ -436,13 +436,16 @@ class SchedulerProxy:
436
436
  return
437
437
 
438
438
  queue.get()
439
+ task._queue.get()
440
+ first_run = True
441
+
439
442
  if task.first_run_timer:
440
443
  await asyncio.sleep(max(0, task.first_run_timer.timestamp() - time.time()))
441
444
 
442
445
  while not queue.qsize():
443
446
  if static.scheduler_sync_servers:
444
447
  task = await self.async_get_task(key)
445
- if (not task or task._queue.qsize()):
448
+ if (not task or (not first_run and task._queue.qsize())):
446
449
  break
447
450
 
448
451
  now = time.time()
@@ -456,21 +459,24 @@ class SchedulerProxy:
456
459
  task = await self.async_get_task(key)
457
460
 
458
461
  if task:
462
+ if first_run:
463
+ task._queue.get()
459
464
  task._last_run_time = time.time() - now
460
465
  task._last_run_timer = datetime.datetime.fromtimestamp(now)
461
466
  task._run_num += 1
462
467
 
463
- if static.scheduler_sync_servers:
464
- sync_server = redis.asyncio.Redis(connection_pool = static.scheduler_sync_servers[1])
465
- await sync_server.hset('CheeseAPI_scheduler_tasks', key, json.dumps(task._to_dict()))
466
- await sync_server.hpexpire('CheeseAPI_scheduler_tasks', int(task.timeout * 1000), key)
468
+ if static.scheduler_sync_servers:
469
+ sync_server = redis.asyncio.Redis(connection_pool = static.scheduler_sync_servers[1])
470
+ await sync_server.hset('CheeseAPI_scheduler_tasks', key, json.dumps(task._to_dict()))
471
+ await sync_server.hpexpire('CheeseAPI_scheduler_tasks', int(task.timeout * 1000), key)
467
472
 
468
- if not task.run_num_completed or (not task or task._queue.qsize()):
473
+ if (not task or task._queue.qsize()) or task.run_num_completed:
469
474
  break
470
475
 
476
+ first_run = False
471
477
  await asyncio.sleep(max(0, task.interval_time - time.time() + now))
472
478
 
473
- if task.auto_remove:
479
+ if not task or task.auto_remove:
474
480
  self._tasks.pop(task.key, None)
475
481
  if static.scheduler_sync_servers is not None:
476
482
  await redis.asyncio.Redis(connection_pool = static.scheduler_sync_servers[1]).hdel('CheeseAPI_scheduler_tasks', key)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: CheeseAPI
3
- Version: 2.0.5b3
3
+ Version: 2.0.5b4
4
4
  Summary: 一款web协程框架
5
5
  Project-URL: Source, https://github.com/CheeseUnknown/CheeseAPI
6
6
  Author-email: Cheese Unknown <cheese@cheese.ren>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "CheeseAPI"
7
- version = "2.0.5-beta.3"
7
+ version = "2.0.5-beta.4"
8
8
  description = "一款web协程框架"
9
9
  readme = "README.md"
10
10
  license-files = { paths = [ "LICENSE" ] }
File without changes
File without changes
File without changes