VirtualBox

Ticket #12127: fail.py

File fail.py, 1.1 KB (added by Mick, 11 years ago)

Demonstrate bug defined by this ticket.

Line 
1"""Bug: Locking in xpcom call when using vboxapi in forked multiprocessing
2process after making a call in the main parent process.
3
4This bug occurs if you have used the manager to talk to VirtualBox in the main
5process followed by trying to use the manager in a forked process.
6
7Looks like the vboxapi has some unrecoverable module global state?
8
9Python: Python 2.7 64bit.
10Operating system: Ubuntu 12.04 x64
11VirtualBox version: 4.2.18r88780
12"""
13import multiprocessing
14import vboxapi
15
16def 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
24def worker():
25 listvms()
26
27if __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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy