Jobs vs tasks vs HassJobs

Hi all,

Looking through the code I see these 3 things that seem to perform similar functionality.

So, what’s the difference between the 3?

HassJob wraps a function and figured out how to run it so by the time it’s called it knows what to do and can avoid the overhead of checking the function type each execution

The other functions on the HomeAssistant object mirror their asyncio counterparts except Home Assistant tracks them to make sure they finish running before start is declared complete

It seems like tasks have futures, whereas jobs don’t. Is that correct?

A few follow up questions:

So, I can’t actually run my own tasks via loop.create_task() or asyncio.create_task()?

Reading the source for the various task methods:

This method must be run in the event loop. If you are using this in your
integration, use the create task methods on the config entry instead.

What exactly does this mean?

Finally, there’s no cancel task?