feat: a lot of a lot

This commit is contained in:
2024-09-01 01:05:11 +03:00
parent 867dfbe597
commit 4ae03284a3
43 changed files with 700 additions and 13 deletions

0
background/__init__.py Normal file
View File

14
background/celery_app.py Normal file
View File

@@ -0,0 +1,14 @@
from celery import Celery
from backend.config import CELERY_BROKER_URL, CELERY_RESULT_BACKEND
celery = Celery(
__name__,
broker=CELERY_BROKER_URL,
backend=CELERY_RESULT_BACKEND
)
celery.conf.result_backend_transport_options = {
'global_keyprefix': 'crm_'
}
from .tasks import *

View File

@@ -0,0 +1 @@
from .marketplace import synchronize_marketplace

View File

@@ -0,0 +1,20 @@
import time
from random import randint
from background.celery_app import celery
@celery.task(name='synchronize_marketplace')
def synchronize_marketplace(marketplace_id: int):
time.sleep(10)
if randint(0,10) % 2 == 0:
return 1
else:
raise Exception('Some error')
# async with session_maker() as session:
# session: AsyncSession
# marketplace: Optional[Marketplace] = await session.get(Marketplace, marketplace_id)
# if not marketplace:
# return
# controller = MarketplaceControllerFactory.get_controller(session, marketplace)
# await controller.synchronize_products()