I have django app. App - client for site with authorization App contains some methods which run periodically, but all methods created auth objects, for example: method runs 10 times, with 10 re-autorization. I tried session to store that object but get error:
def get_api_instance(request):
if 'api' not in request.session:
api = auth()
request.session['api'] = api
return request.session['api']
<****api.api.Api object at 0x7fe30d155550> is not JSON serializable
Can you recommend something?
UPD: in simple python script i can create global variable:
api_var = None
def get_api():
if not api_var:
api_var = auth()
return api_var
def periodic():
api = get_api_var()
....