3.0.ipv8.util ============= .. py:module:: 3.0.ipv8.util Attributes ---------- .. autoapisummary:: 3.0.ipv8.util.maximum_integer 3.0.ipv8.util.int2byte 3.0.ipv8.util.byte2int 3.0.ipv8.util.T Functions --------- .. autoapisummary:: 3.0.ipv8.util.succeed 3.0.ipv8.util.fail 3.0.ipv8.util.maybe_coroutine 3.0.ipv8.util.coroutine 3.0.ipv8.util.strip_sha1_padding 3.0.ipv8.util.create_event_with_signals 3.0.ipv8.util.run_forever Module Contents --------------- .. py:data:: maximum_integer :value: 2147483647 .. py:data:: int2byte .. py:data:: byte2int .. py:data:: T .. py:function:: succeed(result: T) -> asyncio.Future[T] Convert a value to a future with the value set as the result. .. py:function:: fail(exception: type | BaseException) -> asyncio.Future Return a future with the given exception set as its exception. .. py:function:: maybe_coroutine(func: Callable, *args: Any, **kwargs) -> collections.abc.Awaitable Ensure the return value of a callable is awaitable. .. py:function:: coroutine(func: Callable) -> Callable[[tuple[Any, Ellipsis], dict[str, Any]], collections.abc.Coroutine[Any, Any, collections.abc.Awaitable]] Ensure that the given callable is awaitable. .. py:function:: strip_sha1_padding(s: bytes) -> bytes Strip the artificial SHA-1 prefix to make it the same byte space as SHA3-256. .. py:function:: create_event_with_signals(*args: int) -> asyncio.Event Creates an event that gets set when certain signals are received. If signals are omitted, the signals SIGINT and SIGTERM will be used. If you don't need access to the event itself, the use of run_forever is preferred. :param args: signals after which the event should be set :type args: [int] :rtype: asyncio.Event .. py:function:: run_forever() -> collections.abc.Coroutine Helper function for waiting until the user presses Ctrl+C. Commonly used for keeping an application alive until shutdown. :rtype: coroutine