Nothing after the return
statement will ever be executed. If you want to call clearcache
, you need to call it before the return
statement.
Also, as a side note, your del
statements aren't really going to do anything either, even if they were placed before the return
. del
effectively just decrements the reference counter in the gc, which will happen when the interpreter exits the function scope anyway.