GithubHelp home page GithubHelp logo

Comments (5)

ydf0509 avatar ydf0509 commented on June 6, 2024 2

image
看文档吧先,按照文档的例子来写就可以了

from funboost.

Hujian99 avatar Hujian99 commented on June 6, 2024

使用eta也存在该报错

from funboost.

ydf0509 avatar ydf0509 commented on June 6, 2024

不知道你的代码是怎么写的,没有贴出你的代码来。

from funboost.

Hujian99 avatar Hujian99 commented on June 6, 2024

已经解决了,顺带问一下,为什么启动消费者后,网络流出速率非常高
image

消费者代码如下:

import asyncio
import os
import sys
from fastapi_libs.ctx.app_ctx import app_context
from fastapi_libs.script_tool.script_alive import script_alive
from fastapi_libs.asyncmsg import MsgEngine

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))

from wk_schedule import app
from wk_schedule.constants.enums import AsyncMsg


@script_alive(__file__.split('/')[-1])
async def run():
    # 心跳检测
    await MsgEngine().send(AsyncMsg.heartbeat, delay=30, script_name="batch_create_task")


async def work():
    async with app_context(app):
        from wk_schedule.logic.notify_service_logic import delay_notify_service_logic
        delay_notify_service_logic.consume() 
        await run()


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    task = asyncio.ensure_future(work())
    loop.run_until_complete(task)

任务代码如下:

@boost("notify_service_queue", broker_kind=BrokerEnum.REDIS_ACK_ABLE, concurrent_mode=ConcurrentModeEnum.ASYNC, max_retry_times=1)
async def notify_service_logic(data_block: dict):
    if await is_time_out(data_block.get("current_overtime")):
        logger.error(f"process data[{data_block.get('data_block')} - {data_block.get('block_sn')}] timeout, current_overtime {data_block.get('current_overtime')}")
        return

    client = await DrainerClient.get(data_block.get('data_type'))
    if client is None:
        logger.error(f"process data[{data_block.get('data_type')} - {data_block.get('block_sn')}] error, not box process")
        return
    # 通知下游服务时记录本次任务触发事件(last_try_time)
    data_block['last_try_time'] = datetime.strftime(datetime.now(), '%Y-%m-%d %H:%M:%S')
    bean = DataBlock()
    await bean.init_bean(data_block)
    state, info = await client.execute(bean)
    if state not in DATA_BLOCK_STATE_RESULT:
        raise ReturnResultValueError(state)
    # 注册更新任务状态
    update_data_block_logic.apply_async({"data_block": data_block, "state": state})

大致逻辑是延迟通知下游服务器

from funboost.

ydf0509 avatar ydf0509 commented on June 6, 2024

boost装饰器可以加个qps

from funboost.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.