This repository was archived by the owner on Jul 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_simple_tasks.py
More file actions
72 lines (58 loc) · 2.01 KB
/
test_simple_tasks.py
File metadata and controls
72 lines (58 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python3
"""
Simple task execution test - focusing on working tasks only.
"""
import time
import sys
from pathlib import Path
# Add the app directory to the Python path
sys.path.insert(0, str(Path(__file__).parent))
from app.core.celery_app import celery_app
def test_simple_tasks():
"""Test simple working tasks."""
print("🚀 Testing Simple Working Tasks")
print("=" * 60)
# Test only tasks that we know work
test_tasks = [
{
'name': 'Health Check',
'task': 'app.tasks.maintenance.health_check',
'args': [],
},
{
'name': 'Generate Corpus Statistics',
'task': 'app.tasks.data_analysis.generate_corpus_statistics',
'args': [],
},
]
for test_case in test_tasks:
print(f"\n🔄 Testing: {test_case['name']}")
print(f" Task: {test_case['task']}")
try:
# Send task
result = celery_app.send_task(
test_case['task'],
args=test_case['args']
)
print(f" Task ID: {result.task_id}")
# Wait for completion
for i in range(15): # Wait up to 15 seconds
status = result.status
if status == 'SUCCESS':
task_result = result.get()
print(f" ✅ Success: {task_result}")
break
elif status == 'FAILURE':
print(f" ❌ Failed: {result.traceback}")
break
elif i == 14:
print(f" ⏱️ Timeout: Status {status}")
break
else:
print(f" Status: {status}", end='\r')
time.sleep(1)
except Exception as e:
print(f" ❌ Exception: {e}")
print(f"\n🎉 Simple task testing completed!")
if __name__ == "__main__":
test_simple_tasks()