fix(core): resolve scheduler async syntax error and robust coroutine handling

- Handle coroutine objects in addition to functions in dispatch_with_entropy
- Prevent RuntimeWarning for unawaited coroutines
This commit is contained in:
Luciabrightcode 2025-12-23 15:07:06 +08:00
parent 357411e57c
commit 88d1d08561

View file

@ -36,7 +36,10 @@ class EntropyScheduler:
# Pre-execution jitter (simulate human hesitation) # Pre-execution jitter (simulate human hesitation)
await asyncio.sleep(random.uniform(0.1, 0.8)) await asyncio.sleep(random.uniform(0.1, 0.8))
# Execute the task
if asyncio.iscoroutinefunction(task): if asyncio.iscoroutinefunction(task):
await task() await task()
elif asyncio.iscoroutine(task):
await task
else: else:
task() task()