Last active
February 11, 2019 04:09
-
-
Save monsterxx03/3d2daef3d9add57d697d95c51a5266b2 to your computer and use it in GitHub Desktop.
test for celery memory leak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import resource | |
import gc | |
from celery import Celery | |
app = Celery() | |
app.conf.update(BROKER_URL='redis://localhost:6379/1') | |
@app.task | |
def dummy(): | |
return '1' | |
def print_mem(): | |
print 'Memory usage: %s (kb)' % resource.getrusage(resource.RUSAGE_SELF).ru_maxrss | |
def run(): | |
for i in range(10000): | |
dummy.delay() | |
if i % 1000 == 0: | |
print_mem() | |
run() | |
print gc.garbage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment