| 1 | """Bug: Locking in xpcom call when using vboxapi in forked multiprocessing
|
|---|
| 2 | process after making a call in the main parent process.
|
|---|
| 3 |
|
|---|
| 4 | This bug occurs if you have used the manager to talk to VirtualBox in the main
|
|---|
| 5 | process followed by trying to use the manager in a forked process.
|
|---|
| 6 |
|
|---|
| 7 | Looks like the vboxapi has some unrecoverable module global state?
|
|---|
| 8 |
|
|---|
| 9 | Python: Python 2.7 64bit.
|
|---|
| 10 | Operating system: Ubuntu 12.04 x64
|
|---|
| 11 | VirtualBox version: 4.2.18r88780
|
|---|
| 12 | """
|
|---|
| 13 | import multiprocessing
|
|---|
| 14 | import vboxapi
|
|---|
| 15 |
|
|---|
| 16 | def listvms():
|
|---|
| 17 | pid = multiprocessing.current_process().pid
|
|---|
| 18 | print("Query from process %s" % pid)
|
|---|
| 19 | manager = vboxapi.VirtualBoxManager(None, None)
|
|---|
| 20 | vbox = manager.getVirtualBox()
|
|---|
| 21 | l = "\n".join([" + " + m.name for m in vbox.getMachines()])
|
|---|
| 22 | print("In process %s:\n%s" % (pid, l))
|
|---|
| 23 |
|
|---|
| 24 | def worker():
|
|---|
| 25 | listvms()
|
|---|
| 26 |
|
|---|
| 27 | if __name__ == '__main__':
|
|---|
| 28 | # Note, if you comment out this listing function here, the subprocesses
|
|---|
| 29 | # will print out the listing without hanging.
|
|---|
| 30 | listvms()
|
|---|
| 31 | p = [multiprocessing.Process(target=worker) for a in range(10)]
|
|---|
| 32 | [a.start() for a in p]
|
|---|
| 33 | [a.join() for a in p]
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|