Skip to content

Commit 7088772

Browse files
celery added
1 parent 6a4bb45 commit 7088772

File tree

12 files changed

+152
-1
lines changed

12 files changed

+152
-1
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ geckodriver.log
1313
# folder (does not include the current folder)
1414
**/*.db
1515

16-
/.vscode
16+
/.vscode
17+
18+
*__pycache__

Celery/READ.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Celery easy workkflow
2+
3+
## commands :
4+
5+
> pip install -r requirements.txt
6+
7+
> https://github.com/celery/celery/
8+
9+
> celery -A test_app.celery worker --pool=solo --loglevel=info
10+
11+
> celery -A test_app.celery worker --loglevel=info
12+
13+
<br />
14+
15+
## Overview :
16+
```
17+
Getting started with celery from strach using redis as broker and postgres as backend to store task results with vanilla pythhon. Had to make to make this document because it was quite confusing .
18+
```
19+
20+
### 1. Setup : Redis
21+
```
22+
If you are on windows :
23+
1. Activate wsl
24+
2. Install any sub linux system or [Ubunut TLS](https://www.microsoft.com/store/productId/9MTTCL66CPXJ )
25+
3. Open Linux cli follow commands :
26+
> sudo apt-add-repository ppa:redislabs/redis
27+
> suo apt-get update
28+
> suo apt-get upgrade
29+
> sudo apt-get install redis-server
30+
> redis-server --version
31+
> redis-server
32+
33+
4. Open another linux terminal :
34+
> redis-cli
35+
> set name nishant
36+
> get name
37+
38+
5. Redis is now ready to use
39+
40+
6. Optional step to view data stored :
41+
> https://redis.io/download/#redis-stack-downloads
42+
43+
7. CELERY_BROKER_URL = 'redis://127.0.0.1:6379/0'
44+
```
45+
46+
<br />
47+
48+
### 2. Setup : Posgres
49+
```
50+
1 . Create a database in postgres
51+
52+
53+
Celery backend url systax : <database_identifier>://<postgres_username>:<password>@<hostname>/<database_name>
54+
55+
My local settings :
56+
CELERY_BACKEND_URL = 'db+postgresql+psycopg2://postgres:root@localhost/celery-db'
57+
```
58+
59+
<br />
60+
61+
### 3. Setup : Celery
62+
```
63+
Celery command :
64+
65+
1. Open a terminal in same project
66+
syntax > celery -A <your_python_file>.<celery_app> worker
67+
> celery -A test_app.celery_app worker --pool=solo --loglevel=info
68+
69+
2. Open Another Terminal :
70+
71+
from task_app import factorial
72+
73+
>> ans = factorial.delay(10)
74+
>> ans._get_task_meta()
75+
>> factorial.name
76+
77+
```
78+
79+
80+
> https://celeryproject.readthedocs.io/zh_CN/latest/userguide/tasks.html
81+
82+
> https://stackoverflow.com/questions/63901790/celery-how-to-get-task-name-by-task-id

Celery/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
celery
2+
sqlalchemy
3+
redis
4+
psycopg2

Celery/screenshots/celery-1.png

156 KB
Loading

Celery/screenshots/celery.png

133 KB
Loading
258 KB
Loading
180 KB
Loading
56.3 KB
Loading

Celery/screenshots/redis-ui.png

40.4 KB
Loading

Celery/screenshots/redis.png

74 KB
Loading

0 commit comments

Comments
 (0)