Pioreactor/pioreactor

turn callback helpers in ODReader to decorators

Open

#359 创建于 2022年12月2日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)Python (17 fork)github user discovery
enhancementfuturegood first issue

仓库指标

Star
 (140 star)
PR 合并指标
 (平均合并 2小时 18分钟) (30 天内合并 1 个 PR)

描述

Current:

from pioreactor.background_jobs.od_reading import ODReader

# example of using callbacks to OD reading...

def hello(self):
    print(f"Hello, {self}!")


def goodbye(self, readings):
    print(f"Goodbye, {self}, witnessed {readings}!")

ODReader.add_pre_read_callback(hello)
ODReader.add_post_read_callback(goodbye)

Desired:

from pioreactor.background_jobs.od_reading import ODReader

# example of using callbacks to OD reading...

@ODReader.add_pre_read_callback
def hello(self):
    print(f"Hello, {self}!")


@ODReader.add_post_read_callback
def goodbye(self, readings):
    print(f"Goodbye, {self}, witnessed {readings}!")

贡献者指南