Pregunta

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.

¿Fue útil?

Solución 2

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.

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top