0

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.

Hussien Mostafa
  • 159
  • 2
  • 18
  • does that answer your question ? https://stackoverflow.com/questions/23611396/python-execute-cat-subprocess-in-parallel – Hussien Mostafa Jan 31 '22 at 12:31
  • Does this answer your question? [running two scripts simultaneously from a master script when each script has multiple threads within it in python](https://stackoverflow.com/questions/60001867/running-two-scripts-simultaneously-from-a-master-script-when-each-script-has-mul) – Hussien Mostafa Jan 31 '22 at 12:34
  • https://stackoverflow.com/questions/6906922/threading-subprocesses-in-python – Hussien Mostafa Jan 31 '22 at 12:36
  • please check all these questions I think they are similar to yours – Hussien Mostafa Jan 31 '22 at 12:37

0 Answers0