I'm working on a project using Python(3.6) and Django(2) in which I need to process too many files from a directory by using Google cloud natural language processing API, but after processing ~100 files it returns an error as:
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:852) [29/Dec/2018 13:27:33] "POST / HTTP/1.1" 500 17751
Here's from views.py
:
def nlp_text_manager(text_path, name):
text = text_path
# encoding = predict_encoding(text_path)
# print('encoding is: {}'.format(encoding))
txt = Path(text_path).read_text(encoding='utf8')
service = discovery.build('language', 'v1beta2', credentials=credentials)
service_request = service.documents().analyzeSentiment(
body={
'document': {
'type': 'PLAIN_TEXT',
'content': txt
}
}
)
response = service_request.execute()
return response