I tried to have the Python program run the processing loop and the broadcast service for the result at the same time using the os.fork () call, something like
pid = os.fork()
if pid == 0:
time.sleep(3)
keep_updating_some_value_while_parent_is_running()
else:
broadcast_value()
Here keep_updating_some_value_while_parent_is_running(), which is executed by the child, stores some value that it continues to update while the parent is running. It actually writes the value to disk so that the parent can easily access it. He discovers that the parent is working, checking that the web service that he is starting is available.
broadcast_value() starts a web service, when accessing it reads the latest value from the disk and serves it.
This implementation works well, but it is unsatisfactory for several reasons:
time.sleep(3) , -
. , 3 , .
( ).
, , , - , , , , ( ), . , , - , .
.
- ,
( , ).
, - , , , , , . , .