AttributeError: class 'jnios.os' has no attribute 'fork' ---- what!!??

Ype Kingma ykingma at accessforall.nl
Thu Oct 4 15:08:06 EDT 2001


Shari,

you wrote:
> 
> Sorry if this sounds simple, but I've just started using jpython.
> 
> I want to call a python script from java.  I thought it would be
> simple!
> 
> Within my java code I am using:
> 
>   PythonInterpreter pInt = new PythonInterpreter();
>   pInt.execfile(".\\Test.py");
> 

Simple enough.

> To call a python script containing:
> 
>   self.pid = os.fork()
> 
> At first I got the error "os has no attribute pipe", which I solved by
> using 'jnios-1.7' to replace Lib\os.py.  My error then mutated into
> the following:
> 
>   AttributeError: class 'jnios.os' has no attribute 'fork'
> 
> So I can't use popen2.py or os.fork().  I'm now at a complete dead
> end, has anyone got any clues?

In J(P)ython you are 'limited' to what the java libraries have to offer
and to what is written in java or pure python.
Unfortunately there is no 'fork' in java and there is no way to provide
it without comprising java's independence from any operating system.
The closest thing is a j(p)ython thread (ie. a java.lang.Thread),
which could be good enough, depending on your requirements. 

Alternatively you could start an interpreter in another process
and use it to communicate with the first one, eg. via sockets or
rmi. I don't know whether jnios also supports pipes between
processes.

> 
> Cheers,
> Shari

Have fun,
Ype

P.S. Posting in jython-users (jython.sourceforge.net) might give you
more answers...

-- 
email at xs4all.nl



More information about the Python-list mailing list