Inject Objek Class Ke Celery Task Di Python – #SolveTheCode

Inject Objek Class Ke Celery Task Di Python - #SolveTheCode
Inject Objek Class Ke Celery Task Di Python - #SolveTheCode

Salah satu issue yang saya temukan waktu bekerja dengan Celery di Python. Saya ada kebutuhan untuk inject business domain class ke argument Celery task, tapi ternyata object class tidak bisa dipakek sebagai argument karna dia bukan JSON Serializable. Solusinya, saya harus ubah dulu object class nya ke tipe data primitive, baru bisa di passing ke argument.

Saya ada bikin video terkait cara solve issue ini, monggo silahkan bisa ditonton:

Saya solve nya pakek library namanya pickle sama codecs. Berikut beberapa bacaan terkait Celery dan library-library tersebut:

– Celery: https://docs.celeryproject.org/en/stable/index.html
– Pickle: https://docs.python.org/3/library/codecs.html
– Codecs: https://docs.python.org/3/library/codecs.html

By dalikewara

Written by Dali Kewara who lives and works as Backend Developer—building useful and unexpected things—in Indonesia. He also has interests in art, writing and journey (traveling). His life motto is "Make it simple but Spectacular!"

Leave a comment

Your email address will not be published. Required fields are marked *