The processes doesn't share the variables in a general operating system
terms. Use some communication mechanism like message passing, shared memory etc to achieve the inter process communication.
are global variables visible to subprocess and changable by subprocess?
-
22-06-2023 - |
Question
A quick question for Python 2.7
Are global variables visible to a subprocess?
Can a subprocess change the values of global variables?
Many thanks.
La solution 2
Autres conseils
No, global variables are not visible to a sub-process. Variables are private to each process. If you want to share variables then you need to use some form of inter-process communication.
Maybe the simplest way is write those into a file and read from the file in another process, although this might take extra time.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow