Skip to content

Commit

Permalink
[AU-4] Working for start with Celerity... Have a problem with a show …
Browse files Browse the repository at this point in the history
…tasks into flower.

See issues:
mher/flower#895
mher/flower#909
mher/flower#787
  • Loading branch information
signmotion committed Dec 2, 2023
1 parent e10afc7 commit 8dd3dca
Show file tree
Hide file tree
Showing 7 changed files with 237 additions and 1 deletion.
61 changes: 61 additions & 0 deletions aides/python/buy_on_ebay_celery/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Python
__pycache__/
*.pyc
*.pyo
*$py.class

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
*.manifest
*.spec

# Log files
pip-log.txt
pip-delete-this-directory.txt
*.log

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
.pytest_cache/
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Environment
.env
.venv
env/
venv/
ENV/

# If you are using PyCharm
.idea/

# vscode
.vscode/settings.json

.env
51 changes: 51 additions & 0 deletions aides/python/buy_on_ebay_celery/.vscode/settings.default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"workbench.colorTheme": "GitHub Dark Default",
"workbench.iconTheme": "fira-code-material-minimal",
"editor.fontFamily": "fira-code-nerd, FiraCode Nerd Font, Consolas, 'Courier New', monospace",
"editor.fontLigatures": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.unicodeHighlight.allowedLocales": {
"ru": true,
"uk": true
},

"editor.accessibilitySupport": "off",
"explorer.confirmDragAndDrop": false,
"redhat.telemetry.enabled": true,
"editor.unicodeHighlight.allowedCharacters": {
"і": true
},
"git.openRepositoryInParentFolders": "never",

"typescript.tsserver.watchOptions": {},

"[dart]": {
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.rulers": [80],
"editor.selectionHighlight": false,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestSelection": "first",
"editor.tabCompletion": "onlySnippets",
"editor.wordBasedSuggestions": false
},
"dart.openDevTools": "flutter",
"dart.warnWhenEditingFilesOutsideWorkspace": false,
"dart.showInspectorNotificationsForWidgetErrors": false,
"dart.debugExternalPackageLibraries": true,
"dart.debugSdkLibraries": true,

"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "ms-python.black-formatter"
},

"[env]": {
"editor.defaultFormatter": "IronGeek.vscode-env"
},

"files.associations": {
".env": "env"
}
}
79 changes: 79 additions & 0 deletions aides/python/buy_on_ebay_celery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Buy on eBay

The server for appraise purchase the items on eBay.

Powered by [Celery & FastAPI](https://testdriven.io/courses/fastapi-celery/getting-started/).

## Run

Work into the Bash terminal. In VSCode bottom pane: open `Git Bash`.

Run the commands below in the root foolder.

### Activate the virtual environment

#### Activate on Windows

```cmd
.\venv\Scripts\activate
```

#### Linux

### Install requirements

```cmd
pip install -r requirements.txt
```

### Install & run Redis

#### Install Redis on Windows

[How do run Redis on Windows?](https://stackoverflow.com/questions/6476945/how-do-i-run-redis-on-windows)

Start Ubuntu and typing:

```cmd
sudo apt-add-repository ppa:redislabs/redis
```

```cmd
sudo apt-get update
```

```cmd
sudo apt-get upgrade
```

```cmd
sudo apt-get install redis-server
```

```cmd
sudo service redis-server restart
```

Check installation:

```cmd
set user:1 "Andrii"
```

```cmd
get user:1
```

### Run Redis on Windows

Start Ubuntu.

```cmd
sudo service redis-server start
```

### Run Celery server

```cmd
celery -A main.celery worker --loglevel=info
```
30 changes: 30 additions & 0 deletions aides/python/buy_on_ebay_celery/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from celery import Celery
from fastapi import FastAPI

app = FastAPI()

# TIMEZONE = "US/Eastern"

celery = Celery(
__name__,
broker="redis://127.0.0.1:6379/0",
backend="redis://127.0.0.1:6379/0",
)

# celery.conf.timezone = TIMEZONE


@app.get("/")
def root():
return {"message": "Hello World"}


@celery.task
def divide(x, y):
import time

# print(f"{x} / {y} = ...")

time.sleep(12)

return x / y
6 changes: 6 additions & 0 deletions aides/python/buy_on_ebay_celery/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fastapi==0.79.0
uvicorn[standard]==0.18.2
celery==5.2.7
redis==4.3.4
tzdata==2023.3
flower==1.2.0
9 changes: 9 additions & 0 deletions aides/python/buy_on_ebay_celery/test.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@hostname = 127.0.0.1
@port = 8000
@host = {{hostname}}:{{port}}

###

GET http://{{host}}/

###
2 changes: 1 addition & 1 deletion aides/python/buy_on_ebay_fastapi/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Buy on eBay FastAPI
# Buy on eBay

The server for appraise purchase the items on eBay.

Expand Down

0 comments on commit 8dd3dca

Please sign in to comment.