I have use case where I have to do some operations on an excel file in python.
There will be 2 processes running in parallel.
The main.py file will open an excel sheet and starts the 3 processes.
- First process - does some calculation on the data from excel.
- Second process - Continuously writes data in the excel at fixed frequency like every 1 min.
Now my requirement is when I start the processes I need to share the excel object between the processes.
I have referred to few examples online and written the below code:
from multiprocessing import Process
def fun(name):
print(f'hello {name}')
def main():
excelObj = OpenExcelApp() # def which opens the excel application and returns the excel object
input_process = Process(target=self.input_data, args=[excelObj]) #input_data def fetches data from db and writes it into the excel file
triggerCalc_process = Process(target= self.trigger_calc, args=[excelObj]) #triggers for calculation
input_process.start()
triggerCalc_process.start()
if __name__ == '__main__':
main()
Can anyone suggest me what am I missing or doing wrong here. Many thanks in advance.