mirror of
https://git.oceanpay.cc/danial/kami_apple_exchage.git
synced 2025-12-18 22:29:09 +00:00
本次提交将后端的任务队列系统从Celery迁移到了Arq,以支持基于协程的任务处理。主要改动包括: - 更新文档和配置文件,反映架构变化。 - 修改健康检查和服务初始化逻辑,以适应Arq的使用。 - 移除与Celery相关的代码,并添加Arq任务定义和调度器。 - 更新Dockerfile和相关脚本,确保Arq worker能够正确运行。 - 调整API和业务服务中的任务处理逻辑,移除对Celery的依赖。 这些改动旨在提高系统的异步处理能力和整体性能。
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Test script to check arq context API"""
|
|
|
|
import asyncio
|
|
from arq.worker import Worker, create_worker
|
|
from arq.connections import RedisSettings
|
|
from arq import cron
|
|
|
|
async def test_task(ctx):
|
|
"""Test task to check context attributes"""
|
|
print(f"Context type: {type(ctx)}")
|
|
print(f"Context attributes: {dir(ctx)}")
|
|
|
|
# Check for common context attributes
|
|
if hasattr(ctx, 'job_id'):
|
|
print(f"job_id: {ctx.job_id}")
|
|
|
|
if hasattr(ctx, 'retry'):
|
|
print("retry method exists")
|
|
# Test if retry is callable
|
|
if callable(ctx.retry):
|
|
print("retry is callable")
|
|
|
|
if hasattr(ctx, 'redis'):
|
|
print("redis connection exists")
|
|
|
|
return {"success": True, "tested_attributes": True}
|
|
|
|
async def main():
|
|
print("Testing arq context API...")
|
|
print(f"arq version: {__import__('arq').__version__}")
|
|
|
|
# Create a simple worker to test context
|
|
worker = Worker(
|
|
functions=[test_task],
|
|
redis_settings=RedisSettings(host='localhost'),
|
|
max_jobs=1
|
|
)
|
|
|
|
print("Worker created successfully")
|
|
|
|
# Test cron function
|
|
try:
|
|
cron_job = cron(test_task, name='test_cron', minute='*')
|
|
print(f"Cron job created: {cron_job}")
|
|
except Exception as e:
|
|
print(f"Cron error: {e}")
|
|
|
|
print("\nContext API test completed")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main()) |