Page 1 of 1

Problems of API usage in multithreading

Posted: 24. Mar 2025, 03:48
by Bladeliu
Hi all,

I tested it's ok to manage VM in a single threading using API. But in multiple threads/processes, it reports "No module named xpcom".
I'm wondering if Virtualbox SDK supports multi-threading/processing, or only Python does not support.

Environment: Centos8, VirtualBox 7.1
SDK: Python binding

Code: Select all

import virtualbox
from multiprocessing.pool import Pool

vm_names = ["vm1", "vm2", "vm3"]
pool = Pool(processes=len(vm_names))

def vm_func(vm_name):
      vb = virtualbox.VirtualBox()      #  error: no module named 'xpcom'

pool = Pool(3)
for name in vm_names:
     pool.apply_async(func=vm_func, args=(name,))