Alex Roitman added the comment:
Will starting a thread while in import also be disallowed? If so, issue 7242
will also become moot...
--
___
Python tracker
<http://bugs.python.org/issue9
Alex Roitman added the comment:
I already worked around this for my use case.
For the future, it would be nice if fork() raised an exception if called during
the import, and if the documentation mentioned that forking while in import is
not allowed
Alex Roitman added the comment:
gregory.p.smith: This is my use case: we had the following situation with the
test scripts at work. Each script is required to import TestApi module in
order to run the tests. That module in turn imported the module that forks,
and in the parent waits for
Alex Roitman added the comment:
1. If fork should not be called during import, it could raise an exception when
invoked from import. But it does not. Is that a bug then? BTW, fork during
import worked with python 2.4 just fine.
2. The whole issue7242 was devoted to work out import locks
Alex Roitman added the comment:
I can place it in a function. But if I execute that function from anything
other than main module, the fork() will be called while import lock is held,
one way or another. It will just happen in another module. So what
Alex Roitman added the comment:
I guess I am missing something here. In a complex program, everything will be
executed in some module or another. Consequently, the module that contains the
fork() call will cause the interpreter to quit.
How can this be worked around, short of placing the
New submission from Alex Roitman :
Importing the module with the following contents results in RuntimeError:
==
import os
pid = os.fork()
if pid == 0:
print "In the child"
else:
print "In the parent"
print "Done\n"
==
R