virtualbox-python
virtualbox-python copied to clipboard
#124 fix register listener
Closes #124
The problem is is virtualbox/library.py
is automatically generated so this likely means we need to update build.py
. Maybe we can update the interface return value script to check for None
values and if None
to return None
? What do you think of this?
The problem is is
virtualbox/library.py
is automatically generated so this likely means we need to updatebuild.py
. Maybe we can update the interface return value script to check forNone
values and ifNone
to returnNone
? What do you think of this?
Hm... What about events.py?
def _event_monitor(callback, event_source, listener, event_interface, quit):
global _callbacks
try:
while not quit.is_set():
try:
event = event_source.get_event(listener, 1000)
except library.VBoxError:
print("Unregistering %s due to VBoxError on get_event" %
listener, file=sys.stderr)
break
if event:
try:
callback(event_interface(event))
except Exception:
print("Unhanded exception in callback: \n%s" %
traceback.format_exc(), file=sys.stderr)
event_source.event_processed(listener, event)
finally:
_callbacks.pop(threading.current_thread().ident, None)
try:
event_source.unregister_listener(listener)
except Exception:
print("Failed to unregister listener %s" % listener,
file=sys.stderr)
maybe we could do something like this?
def _event_monitor(callback, event_source, listener, event_interface, quit):
global _callbacks
try:
while not quit.is_set():
try:
event = event_source.get_event(listener, 1000)
except library.VBoxError:
print("Unregistering %s due to VBoxError on get_event" %
listener, file=sys.stderr)
break
event_type = getattr(event, 'type_p', None)
if event_type :
try:
callback(event_interface(event))
except Exception:
print("Unhanded exception in callback: \n%s" %
event_type = getattr(event, 'type_p', None)
if not event_type means its None event