Gunicorn not able to load up Global Variables

I have a Django project deployed with Gunicorn configured in the backend, the project generates several files every day for 4 different services (let's say service A, B, C, and D), and the files are named as servicename_date the date is being picked up by a global variable TODAY.

from datetime import date

def func_A():
    df.to_csv(os.path.join(os.getcwd(), "data","service_A" + "_" + TODAY + ".csv"), index=False)

def func_B():
    df.to_csv(os.path.join(os.getcwd(), "data","service_B" + "_" + TODAY + ".csv"), index=False)

def func_C():
    today =
    df.to_csv(os.path.join(os.getcwd(), "data","service_C" + "_" + today + ".csv"), index=False)

def func_D():
    today =
    df.to_csv(os.path.join(os.getcwd(), "data","service_D" + "_" + today + ".csv"), index=False)

and this global variable is used in different functions in the same file.

The problem is the value of TODAY is not always correct on the server. Sometimes it is correct I,e Today's date sometimes it picks up previous dates.

The problem only occurs with the services that use Global variables I,e Service A and B, other services that use variables initialized inside their specific function don't face this issue I,e Service C and D.

I have tried to replicate this issue on my local however wasn't able to replicate the issue.

Back to Top