none
I am unable to load full pickle list on azure web app RRS feed

  • Question

  • I have an Azure Web app stacked on python and running a flask app to call a function and this function returns a list of country name which I have saved in pickle file. Lets say I have a total of 100 countries so whenever I run the app it reads 100 countries from that pickle file but sometimes it's stuck to 98 or 99 countries so not sure where I am loosing 1 or 2 countries from that list. This issue only happens on azure web app otherwise it retrieves full 100 countries. Below is the code I'm using to load the pickle file having country list of 100:
    ```
    import pickle
    path=os.getcwd()+'\\'
    def example():
        country_list=pickle.load(open(path+"support_file/country_list.p","rb"))
        print(len(country_list))
        return country_list
    ```
    Here is my flask app.py to call the function:
    ```
    from other_file import example
    from flask import Flask, request

    app = Flask(__name__)

    @app.route("/", methods=["POST", "GET"])
    def query():
        if request.method == "POST":
            return example()
        else:
            return "Hello!"


    if __name__ == "__main__":
        app.run()
    ```

    The above list is then used in a function and my output depends on all the elements of this list but if an element or two goes missing while loading this pickle then my output changes. So I'm not missing out this elements consistently but it happens for say 1 in every 20 times, so is this a problem of Azure Web app or is something wrong with my pickle? I tried to recreate the pickle but same problem keeps on coming up once in a while.
    Thursday, August 6, 2020 9:56 AM