celery.utils.debug

Использование памяти при выборке

Этот модуль можно использовать для диагностики и выборки использования памяти частями вашего приложения.

Например, для выборки использования памяти при вызове задач можно сделать следующее:

from celery.utils.debug import sample_mem, memdump

from tasks import add


try:
    for i in range(100):
        for j in range(100):
            add.delay(i, j)
        sample_mem()
finally:
    memdump()

Справочник по API

Utilities for debugging memory usage, blocking calls, etc.

celery.utils.debug.sample_mem()[исходный код]

Sample RSS memory usage.

Statistics can then be output by calling memdump().

celery.utils.debug.memdump(samples=10, file=None)[исходный код]

Dump memory statistics.

Will print a sample of all RSS memory samples added by calling sample_mem(), and in addition print used RSS memory after gc.collect().

celery.utils.debug.sample(x, n, k=0)[исходный код]

Given a list x a sample of length n of that list is returned.

For example, if n is 10, and x has 100 items, a list of every tenth. item is returned.

k can be used as offset.

celery.utils.debug.mem_rss()[исходный код]

Return RSS memory usage as a humanized string.

celery.utils.debug.ps()[исходный код]

Return the global psutil.Process instance.

Примечание

Returns None if psutil is not installed.

Вернуться на верх