実行をスケジュールするためのデコレーターを使用して関数を追加しようとしていますが、次のエラーが発生します。
ValueError: This Job cannot be serialized since the reference to its callable (<function inner at 0x7f1c900527d0>) could not be determined. Consider giving a textual reference (module:function name) instead.
私の機能は
@my_decorator
def my_function(id=None):
print id
次のように追加します。
my_scheduler.add_job(function, 'interval',minutes=1)
デコレータで関数を追加することは可能ですか? 何か案は?
回避策として、内部定義を定義してデコレーターも呼び出すことができますが、それは悪い解決策と考えており、直接使用することをお勧めします
回避策:
def outer(id=None):
@my_decorator
def my_function(id=None):
print id
my_function(id)
my_scheduler.add_job(outer, 'interval',minutes=1)