Discussions related to Visual Prolog
User avatar
drspro2
VIP Member
Posts: 97
Joined: 28 Apr 2006 12:03

pipes vp and python

Unread post by drspro2 »

I am trying to call the pipe-server in Vp , so that vp writes to a pipe,

then in Python i try to read from this pipe server, it doesnt connect,

can it be the unequal with the pipe name?, the pipe is not written anywhere as i file, to be able to check the name ?.

I created a chromium web browser in python, and now i would like Vp and python communicate through the pipe system, so that it can open a new Url ( when vp writes to the pipe) without opening a new window.

Vp code : ( to write to the pipe )

Code: Select all

    PipeName = pipeStream::makeLocalPipeName("pipe_vp_read"),     Pipe = pipeStream::openServer(PipeName),     Pipe:writef("\n % % %","ooo","eeee","\n"),     Pipe:flush(),     Pipe:close(),!.
Python code: ( to read from the pipe )

<pre>import os, time, sys

pipe_name = 'pipe_vp_read'

def paread( ):
pipein = open(pipe_name, 'r')
while True:
print 'begin read '
line = pipein.readline()[:-1]
print 'Parent %d got "%s" at %s' % (os.getpid(), line, time.time( ))

paread()
</pre>

Python exits with :

pipein = open(pipe_name, 'r')
IOError: [Errno 2] No such file or directory: 'pipe_vp_read'
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

A pipe name has the form \\<server>\pipe\<name>.

The server side of a pipe is always on the machine that opens it, so it must have the form \\.\pipe\<name>. pipeStream::makeLocalPipeName creates such a name.

If your python code is running on the same computer (which I believe it is) then it should also use the pipe name \\.\pipe\<name>

See also Pipe Names.
Regards Thomas Linder Puls
PDC
Post Reply