How to create custom job?

Creating archive, sending through peers asynchronously creates jobs. How to create custom job in python plugin?

I want to get frame raw content and store it in a file. But i have some logic in STABLE_STUDY ChangeType, so i have to run NEW_INSTANCE logic in jobs:

if changeType == orthanc.ChangeType.NEW_INSTANCE:
    a = orthanc.RestApiGet('/instances/%s' % resource)
    b = requests.get('http://localhost:8042/dicom-web/.../frames/1')
    file_path = os.path.join(cacheFolder, '1')
    os.makedirs(cacheFolder, exist_ok=True)
    
    with open(file_path, 'wb') as file:
        file.write(b.content)

This is currently not possible.