Pergunta

I have a code that is running 24/7. And, I am wondering if there is any methodology which I could use to allow me to make changes to the variables in real-time without invoking any error? Had been using raw_input() but this 'stops' the program since it's running sequentially.

My idea is to use a while true loop:

while true:
    ...
    ...

and for the first few loops, it'll use the default catch all values that i have pre-programmed into the system. As it's running, I'll like to make changes to some constant terms (which act as control) in 'real-time'. So, in the next loop and beyond, it'll use the new values rather than the pre-programmed version.

Foi útil?

Solução

Some of your code or details of what you are trying to do would help.

But one way to do it is to have two processes, one process that reads from standard in with raw_input(), we can call it p1; and one that handles the data structure, in this case the list, we call it p2.

The two processes could communicate with message passing using sockets or what ever you want.

Then to be sure to avoid race conditions that new data is read in p1, but not yet updated in p2. Thus p2 will carry on and use the out of date data. One way to do this is using locks.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top