I have a for loop that appends in each iteration something to a list. After each 50 iterations, I need to use this list, do some operations with it, and save it as pickle in some directory. Is it somehow possible to outsource the processing of the list after each 50 operations to a new console, such that the for loop immediately continues (i.e., the processing of the list after each 50 operations is done in another console and the for loop continues without waiting for the processing to be done)?
def do_something(x):
#some operation
def execute_in_another_console(y):
#open another console
#upload there y
#perform some operations
#save results in some directory as pickle
list = []
for i in range(1000):
list.append(do_something(i))
if i % 50 == 0:
list_new_console = list.copy()
list = []
execute_in_another_console(list_new_console)
Please note that I cannot use a parallel for loop due to some server issues.