blivet.events package

Submodules

blivet.events.changes module

class blivet.events.changes.ActionCanceled

Bases: blivet.util.TheDefaultNamedTuple

class blivet.events.changes.AttributeChanged

Bases: blivet.util.TheDefaultNamedTuple

class blivet.events.changes.DeviceAdded

Bases: blivet.util.TheDefaultNamedTuple

class blivet.events.changes.DeviceRemoved

Bases: blivet.util.TheDefaultNamedTuple

class blivet.events.changes.ParentAdded

Bases: blivet.util.TheDefaultNamedTuple

class blivet.events.changes.ParentRemoved

Bases: blivet.util.TheDefaultNamedTuple

blivet.events.changes.data = <_thread._local object>

Thread-local data for event handler threads.

blivet.events.handler module

class blivet.events.handler.EventHandlerMixin

Bases: object

handle_event(event, notify_cb)

Handle an event on a block device.

:param Event event: information about the event :param callable notify_cb: notification callback

TODO: Rename all this stuff so it’s explicit that it only handles uevents.

blivet.events.manager module

class blivet.events.manager.Event(action, device, info=None)

Bases: blivet.util.ObjectID

An external event.

Parameters:
  • action (str) – a string describing the type of event
  • device (str) – (friendly) basename of device event operated on
  • info – information about the device
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 (str) – ignore events on the named device
  • action (str) – ignore events of the specified type
  • partitions (bool) – also match events on child partitions

device of None means mask events on all devices action of None means mask all event types

disable()

Disable monitoring and handling of events.

enable()

Enable monitoring and handling of events.

Raises:EventManagerError if no callback defined
enabled
error_cb

callback to run when an exception occurrs 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 an error_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.

handler_cb

the main event handler

notify_cb

notification handler that runs after the main event handler

remove_mask(mask)
class blivet.events.manager.EventMask(device=None, action=None, partitions=False)

Bases: blivet.util.ObjectID

Specification of events to ignore.

Parameters:
  • device (str) – basename of device to mask events on
  • action (str) – action type to mask events of
  • partitions (bool) – also match events on child partitions
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: blivet.events.manager.EventManager

disable()

Disable monitoring and handling of block device uevents.

enable()

Enable monitoring and handling of block device uevents.

enabled
blivet.events.manager.validate_cb(cb, kwargs=None, arg_count=None)

Validate signature of callback function, returning True on success.

Module contents