blivet.events package¶
Submodules¶
blivet.events.changes module¶
- class blivet.events.changes.ActionCanceled(*args, **kwargs)¶
Bases:
TheDefaultNamedTuple
Create new instance of ActionCanceled(action,)
- class blivet.events.changes.AttributeChanged(*args, **kwargs)¶
Bases:
TheDefaultNamedTuple
Create new instance of AttrChanged(device, fmt, attr, old, new)
- class blivet.events.changes.DeviceAdded(*args, **kwargs)¶
Bases:
TheDefaultNamedTuple
Create new instance of DeviceAdded(device,)
- class blivet.events.changes.DeviceRemoved(*args, **kwargs)¶
Bases:
TheDefaultNamedTuple
Create new instance of DeviceRemoved(device,)
- class blivet.events.changes.ParentAdded(*args, **kwargs)¶
Bases:
TheDefaultNamedTuple
Create new instance of ListItemAdded(device, item)
- class blivet.events.changes.ParentRemoved(*args, **kwargs)¶
Bases:
TheDefaultNamedTuple
Create new instance of ListItemRemoved(device, item)
- blivet.events.changes.action_removed_cb(action)¶
- blivet.events.changes.attribute_changed_cb(device, attr, old, new, fmt=None)¶
- blivet.events.changes.data = <_thread._local object>¶
Thread-local data for event handler threads.
- blivet.events.changes.device_added_cb(device)¶
- blivet.events.changes.device_removed_cb(device)¶
- blivet.events.changes.disable_callbacks()¶
- blivet.events.changes.enable_callbacks()¶
- blivet.events.changes.parent_added_cb(device, parent)¶
- blivet.events.changes.parent_removed_cb(device, parent)¶
- blivet.events.changes.record_change(change)¶
blivet.events.handler module¶
blivet.events.manager module¶
- class blivet.events.manager.EventManager(handler_cb=None, notify_cb=None, error_cb=None)¶
Bases:
object
- add_mask(device=None, action=None, partitions=False)¶
Add an event mask and return the new
EventMask
.- Parameters:
device of None means mask events on all devices action of None means mask all event types
- abstract disable()¶
Disable monitoring and handling of events.
- abstract enable()¶
Enable monitoring and handling of events.
- Raises:
EventManagerError
if no callback defined
- abstract property enabled¶
- property error_cb¶
callback to run when an exception occurs in a thread.
- handle_event(*args, **kwargs)¶
Handle an event by running the registered handler.
Currently the handler is run in a separate thread. This removes any threading-related expectations about the behavior of whatever is telling us about the events.
Unhandled exceptions in event handler threads present a bit of a challenge. Generally, an unhandled exception in an event handler thread should be fatal because of the high likelihood that the error left the
DeviceTree
in an inconsistent state. Since exceptions that occur in threads are not reported to the main thread, we have to try to notify it ourselves. Ideally, the calling application will have registered anerror_cb
, which we can use to notify it of the exception. If no callback has been set we can only wait until the next time the calling application makes a call into blivet, at which point we can raise the original exception.
- property handler_cb¶
the main event handler
- property notify_cb¶
notification handler that runs after the main event handler
- remove_mask(mask)¶
- class blivet.events.manager.EventMask(*args, **kwargs)¶
Bases:
ObjectID
Specification of events to ignore.
- Parameters:
- match(event)¶
Return True if this mask applies to the specified event.
..note:
A mask whose device is a partitioned disk will match events on its partitions.
- class blivet.events.manager.UdevEventManager(handler_cb=None, notify_cb=None)¶
Bases:
EventManager
- disable()¶
Disable monitoring and handling of block device uevents.
- enable()¶
Enable monitoring and handling of block device uevents.
- property enabled¶
- blivet.events.manager.validate_cb(cb, kwargs=None, arg_count=None)¶
Validate signature of callback function, returning True on success.