Hi All,
Anyone else encountered this kind of problem?
What I’m trying to do:
Read a text anvil media file into a text file.
What I’ve tried and what’s not working:
This works as a server function but not as a background task.
Error Thrown
anvil.server.InternalError: Internal server error: 67452d489095
at /home/anvil/.downlink-sources/downlink-2023-03-23-12-44-41/anvil/_threaded_server.py, line 435
called from /home/anvil/.downlink-sources/downlink-2023-03-23-12-44-41/anvil/server.py, line 55
called from /home/anvil/.downlink-sources/downlink-2023-03-23-12-44-41/anvil/_server.py, line 452
called from /home/anvil/.downlink-sources/downlink-2023-03-23-12-44-41/anvil/_server.py, line 483
called from /home/anvil/.downlink-sources/downlink-2023-03-23-12-44-41/anvil/media.py, line 47
Code Sample:
This secion of code is called from a background task. It worked when it was a session call, but broke when making into a background task
def Read_File_To_Text(CurrentFile):
#Open file with media reader and output text
with anvil.media.open(CurrentFile) as f: #THIS IS THE LINE THAT THROWS THE ERROR
TXT_Output = f.readlines()
for Index in range(0,len(TXT_Output)):
TXT_Output[Index] = TXT_Output[Index].decode('utf-8')
return TXT_Output;