Pioreactor/pioreactor

turn callback helpers in ODReader to decorators

Open

#359 aperta il 2 dic 2022

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)Python (17 fork)github user discovery
enhancementfuturegood first issue

Metriche repository

Star
 (140 star)
Metriche merge PR
 (Merge medio 2h 18m) (1 PR mergiata in 30 g)

Descrizione

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}!")

Guida contributor