You mean you get delays writing to a standard file and polling it? You can use named pipes.
Note: This assumes that named pipes work reliably in the PA environment - someone more familiar with the architecture than I would need to jump in to answer that one.
This is best illustrated by example. Leave this Python script running in a bash window - this would be your long-running process:
import os
import sys
PIPE_NAME = os.path.expanduser("~/test_pipe")
def watch_pipe(name):
while True:
with open(name, "r") as fd:
while True:
line = fd.readline()
if not line:
break
print "Got: '%s'" % (line.strip(),)
print "Writer closed pipe - reopening"
def main():
if not os.path.exists(PIPE_NAME):
os.mkfifo(PIPE_NAME)
watch_pipe(PIPE_NAME)
if __name__ == "__main__":
sys.exit(main())
Then open a new browser window with a new bash window and run this script - this would be whatever needs to communicate with the long-running process:
import os
import sys
import time
PIPE_NAME = os.path.expanduser("~/test_pipe")
def main():
with open(PIPE_NAME, "w") as fd:
for i in range(5):
fd.write("hello, world\n")
fd.flush()
time.sleep(2)
if __name__ == "__main__":
sys.exit(main())
There are some subtleties with named pipes, such as needing to reopen when the writer closes, but their usage is well documented all over the web - Google is your friend.