def save_plugin(sender, instance, created, **kwargs): """ Decorate chosen method """ from apps.common.decorators import collect_stats, decorate, undecorate if not created: undecorate(path=instance.path) decorate(collect_stats, **MethodStatsCollectorPlugin.objects.filter(pk=instance.pk).values()[0])
def init_method_stats_collectors(_celery_task): """ Initiate collect_stats decorators on system start """ for instance_values in MethodStatsCollectorPlugin.objects.values(): decorate(collect_stats, **instance_values)