Pipe not working with executable
I have put together a program that gathers data from an html/php UI and
sends it via a pipe to a Python application (it is one way only - read
from Python script). Up until now I have been running and de-bugging the
code using IDLE, however, now is the time to make the python script
executable so it can be run from the command line. The problem is that
although the pipe works fine when run in IDLE i get a strange response
when running from the command line. The pipe is set up as follows:
pipe_name = 'testpipe'
pipein = os.open(pipe_name, os.O_RDWR)
if not os.path.exists(pipe_name):
os.mkfifo(pipe_name)
I then use the select.select command to detect input on the pipe:
inputdata,outputdata,exceptions = select.select([tcpCliSock,pipein],[],[])
If data is detected on the pipe I read it by:
line = os.read(pipein,BUFSIZ)
The strange thing is that if there is already data on the pipe when the
executable is first run it reads in ok and displays as expected which
suggests the pipe can be read from the executable. However, if there isn't
and I submit data to the pipe via the UI the command window is unable to
read it and returns an empty array and then errors because the rest of the
code can't operate on the array that should be there. I don't really
understand what could be the issue so any clues would be helpful.
No comments:
Post a Comment