celery.utils.debug

Sampling Memory Usage

This module can be used to diagnose and sample the memory usage used by parts of your application.

E.g to sample the memory usage of calling tasks you can do this:

  1. from celery.utils.debug import sample_mem, memdump
  2. from tasks import add
  3. try:
  4. for i in range(100):
  5. for j in range(100):
  6. add.delay(i, j)
  7. sample_mem()
  8. finally:
  9. memdump()

API Reference

celery.utils.debug

Utilities for debugging memory usage.

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.

E.g. if n is 10, and x has 100 items, a list of every 10th 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, or None if psutil is not installed.