Skip to content
Advertisement

How to dynamically change the value of variable in functions while using multiprocessing

how can i dynamically change the value of lis so that every second it’ll output a list in which the last element is 2x the last element of the previous list .

JavaScript

i need the output to be something like this

JavaScript

but right now the output is

JavaScript

I tried using global lis but that didnt work either.

Advertisement

Answer

You can achieve desired behavior using multiprocessing.Manager.

Managers provide a way to create data which can be shared between different processes. You can read more about it here.

Based on example from Server process section you can rewrite your code like this:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement