How use Python scalene for memory profiling inside a celery task

1.8k Views Asked by At

I need to debug a celery task for its memory and CPU using scalene. https://github.com/emeryberger/scalene

When I read the docs, it only states to debug using console i.e. python -m scalene test/testme.py or scalene test/testme.py. I want to know if it is possible to use some kind of context manager inside my program for profiling which can output in a file? Only a few lines of code look suspicious to me so I was wonder if that an option.

Thanks.

1

There are 1 best solutions below

0
On

Scalene author here. It is not yet an option; doing this with memory profiling seems tricky since it relies on loading a special runtime library. For CPU profiling only, it’s possible, but honestly I think it’s worth just giving it a try at the command line!