myapp.py
---- import statements ---
parser = None
app = Flask(__name__)
@app.route('/xxxxxx/yyy')
def markDealStatud():
text = 'matthew honnibal created spacy library'
parsedData = parser(text.decode("utf-8"))
xxxxxxxxxxxxx
xxxxxxxxxxxx
def initSpacy():
global parser
parser = English()
if __name__ == '__main__':
initSpacy()
app.run()
if __name__ == 'myapp':
initSpacy()
when i run this app in development mode, __main__
will execute and it will instantiate spacy only once and i will use that.
For production we are using apache server mod_wsgi configuration. similarly i want to instantiate it once(myapp) and use the same obj. In my configuration it is instantiating for each request. Suggest some solution plz.
Environment
Operating System: Linux
Python Version Used: 2.7
Environment Information: apache mod_wsgi deployment