Python 两次访问系统dbus会导致分段错误

Python 两次访问系统dbus会导致分段错误,python,segmentation-fault,race-condition,glib,dbus,Python,Segmentation Fault,Race Condition,Glib,Dbus,Dbus让我有些头痛。即调用SystemBus()两次,在大多数情况下都会出现分段错误。有时它会给出一些其他的随机错误,所以我想这是一个竞争条件 from dbus.mainloop.glib import DBusGMainLoop from time import sleep import threading import dbus, gobject # Monitor usb on a separate thread def monitor_usb(): DBusGMainLo

Dbus让我有些头痛。即调用SystemBus()两次,在大多数情况下都会出现分段错误。有时它会给出一些其他的随机错误,所以我想这是一个竞争条件

from dbus.mainloop.glib import DBusGMainLoop
from time import sleep
import threading
import dbus, gobject


# Monitor usb on a separate thread
def monitor_usb():
    DBusGMainLoop(set_as_default=True)
    dbus.SystemBus()                      # Probably source of error
    gobject.threads_init()
    gobject.MainLoop().run()
thread=threading.Thread(target=monitor_usb)
thread.daemon=True
thread.start()


# Calling this while monitor_usb is running
# will cause segmentation fault
dbus.SystemBus()
sleep(10)
有办法解决这个问题吗