odd runtime error



So I'm not subscribed to python-list but would like to get an answer
to my question. I've made a small test program that dumps a
RuntimeError and I'd like to know why.

$ python test2.py
doing stuff
Traceback (most recent call last):
File "test2.py", line 3, in <module>
import test
RuntimeError: not holding the import lock
child 3693 exited with 256
$

Here's the setup, there's two files test.py and test2.py

$ cat test.py
#!/usr/bin/python

import os, sys

if os.fork() == 0:
print "doing stuff"
sys.exit()

print "child %d exited with %d" % os.wait()
$ cat test2.py
#!/usr/bin/python

import test
$

I understand that sys.exit() is really just doing a `raise
SystemExit(0)' and the RuntimeError shows up with that as well. If you
change out sys.exit with os._exit(0) then it doesn't show dump the
RuntimeError. Also, this seems to be a python2.6 and python2.7 issue.
Python3 doesn't have this issue. I haven't checked with python2.5 or
before yet.

I was more curious about what this behavior is and why python is doing
things this way. I've scoured the python documentation and can't seem
to figure out why.

Thanks,
- David Brown
.



Relevant Pages

  • Re: "RuntimeError: dictionary changed size during iteration" ; Good atomic copy operations?
    ... Python object trees consist only of dicts and lists as far as variable non-atomic datastructures are concerned. ... AFAIK about the current Python implementation: This RuntimeError is only thrown "during true Iteration over dict/list, when the number of items changes". ...
    (comp.lang.python)
  • Re: odd runtime error
    ... I've made a small test program that dumps a ... RuntimeError and I'd like to know why. ... $ python test2.py ... $ cat test.py ...
    (comp.lang.python)
  • Re: odd runtime error
    ... I've made a small test program that dumps a ... | RuntimeError and I'd like to know why. ... | I was more curious about what this behavior is and why python is doing ... Python takes a lock during imports - this stops multiple threads ...
    (comp.lang.python)
  • Re: odd runtime error
    ... I've made a small test program that dumps a ... | RuntimeError and I'd like to know why. ... | I was more curious about what this behavior is and why python is doing ... Python takes a lock during imports - this stops multiple threads ...
    (comp.lang.python)
  • Re: Unification of Methods and Functions
    ... class Foo: ... A Python method requires a special first ... Mammal.showshows characteristics to do with Mammals, ... > Nothing in the Bovine class can affect anything in a Cat. ...
    (comp.lang.python)