ros2cli.daemon.daemonize module

class ros2cli.daemon.daemonize.PicklerForProcess(process, *args, **kwargs)

Bases: Pickler

Pickle objects for subprocess.

This pickle.Pickler subclass sends serialized objects to the given process through its stdin pipe. It can serialize and send inheritable sockets and file descriptors.

dump(*args, **kwargs)

Write a pickled representation of the given object to the open file.

static load_socket(data)
reduce_event(obj)
reduce_socket(obj)
ros2cli.daemon.daemonize.daemonize(callable_, tags={}, timeout=None, debug=False)

Spawn a callable object as a daemon.

The callable object is pickled and sent for execution via the stdin pipe, which is closed immediately after deserialization succeeds. The callable object may hold inheritable sockets and file descriptors.

Parameters:
  • callable – callable object to be daemonized.

  • tags – optional key-value pairs to show up as command-line ‘–key value’ arguments of the daemon process. Useful for identification in the OS process list.

  • timeout – optional duration, in seconds, to wait for the daemon to be ready. Non-positive durations will result in an indefinite wait.

  • debug – if True, the daemon process will not be detached and share both stdout and stderr streams with its parent process.

ros2cli.daemon.daemonize.main()

Execute incoming, serialized callable.

See daemonize() for further reference.