When I run the cell below, and there is no file with the same name as filename, it executes perfectly. But on subsequent runs, if there exists a file with the same name, the kernel gets busy and execution never happens.
I added the flush line, but still no execution.
If I change my filename then again it executes once. After the file is created the cell does not executes.
Below is the code:
import json
import copy
filename = "my_first_match_data.json"
save_data = {'Match': "test", "test2"}
match_data = {'Match': "test", "test2"}
save_data['Match'] = copy.deepcopy(match_data)
try:
# if I am not appending to an already existing file, it causes some unforeseen error.
with open(filename, 'w') as json_file:
json.dump(save_data, json_file)
json_file.flush()
print(f"Data successfully saved to {filename}")
except IOError as e:
print(f"Error saving data to file: {e}")