ep1cman / unifi-protect-backup

Python tool to backup unifi event clips in realtime
MIT License
657 stars 32 forks source link

Runtime error "TypeError: object async_generator can't be used in 'await' expression" with SKIP_MISSING=true #110

Closed Ik-12 closed 1 year ago

Ik-12 commented 1 year ago

Description

Starting the official docker container with configuration option SKIP_MISSING=true causes runtime error immediately at startup. Setting SKIP_MISSING=false with otherwise same configuration works.

What I Did

Configuration:

version: '3.3'
services:
  unifi-protect-backup:
    image: ghcr.io/ep1cman/unifi-protect-backup
    container_name: unifi-protect-backup
    environment:
      - UFP_USERNAME=protect-backup-client
      - UFP_PASSWORD=REDACTED
      - UFP_ADDRESS=192.168.x.x
      - UFP_PORT=443
      - UFP_SSL_VERIFY=false
      - RCLONE_DESTINATION=gdrive:/Unifi-backup/
      - RCLONE_RETENTION=90d
      - TZ=Europe/Helsinki
      - VERBOSE=
      - SKIP_MISSING=true
      - APPRISE_NOTIFIERS=REDACTED
    volumes:
      - /opt/upb/data:/data
      - /opt/upb/config:/config/
      - /opt/upb/config/rclone/rclone.conf:/config/rclone/rclone.conf
    restart: always

Output:

2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :  Config:
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    address='192.168.x.x'
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    port=443
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    username='protect-backup-client'
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    password=REDACTED
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    verify_ssl=False
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    rclone_destination='gdrive:/Unifi-backup/'
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    retention=relativedelta(days=+90)
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    rclone_args=''
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    rclone_purge_args=''
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    ignore_cameras=()
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    verbose=1
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    detection_types=['motion', 'person', 'vehicle', 'ring']
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    file_structure_format='{camera_name}/{event.start:%Y-%m-%d}/{event.end:%Y-%m-%dT%H-%M-%S} {detection_type}.mp4'
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    sqlite_path='/config/database/events.sqlite'
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    download_buffer_size=512.0MiB
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    purge_interval=relativedelta(days=+1)
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    apprise_notifiers=(****)
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    skip_missing=True
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :    download_rate_limit=None events per minute
2023-10-31 18:33:23 [   INFO    ] unifi_protect_backup.unifi_protect_backup_core :  Starting...
2023-10-31 18:33:23 [   INFO    ] unifi_protect_backup.unifi_protect_backup_core :  Checking rclone configuration...
2023-10-31 18:33:23 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :  rclone found: /usr/bin/rclone
2023-10-31 18:33:31 [   INFO    ] unifi_protect_backup.unifi_protect_backup_core :  Connecting to Unifi Protect...
2023-10-31 18:33:32 [   INFO    ] unifi_protect_backup.unifi_protect_backup_core :  Found cameras:
2023-10-31 18:33:32 [   INFO    ] unifi_protect_backup.unifi_protect_backup_core :   - 62ab6dd800708f03e7000f43: Kitchen
2023-10-31 18:33:32 [   INFO    ] unifi_protect_backup.unifi_protect_backup_core :   - 62fd23ac02b97003e700f87a: Backyard
2023-10-31 18:33:32 [   INFO    ] unifi_protect_backup.unifi_protect_backup_core :   - 634c01f403da5b03e7017a29: Garage
2023-10-31 18:33:32 [   INFO    ] unifi_protect_backup.unifi_protect_backup_core :   - 62965cbc0035de03e70096fe: Front Door
2023-10-31 18:33:32 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :  NVR TZ: Europe/Helsinki
2023-10-31 18:33:32 [   DEBUG   ] unifi_protect_backup.unifi_protect_backup_core :  Local TZ: EET
2023-10-31 18:33:32 [   DEBUG   ] unifi_protect_backup.downloader            :  ffprobe found: /usr/bin/ffprobe
2023-10-31 18:33:32 [   INFO    ] unifi_protect_backup.unifi_protect_backup_core :  Ignoring missing events
2023-10-31 18:33:32 [   ERROR   ] unifi_protect_backup.unifi_protect_backup_core :  Unexpected exception occurred in main loop:
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/unifi_protect_backup/unifi_protect_backup_core.py", line 270, in start
    await missing.ignore_missing()
  File "/usr/lib/python3.10/site-packages/unifi_protect_backup/missing_event_checker.py", line 125, in ignore_missing
    wanted_events = await self._get_missing_events()
TypeError: object async_generator can't be used in 'await' expression
2023-10-31 18:33:42 [   ERROR   ] aiorun                                     :  Unhandled exception; stopping loop: 'Task exception was never retrieved'
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/aiorun.py", line 219, in new_coro
    await coro
  File "/usr/lib/python3.10/site-packages/unifi_protect_backup/unifi_protect_backup_core.py", line 270, in start
    await missing.ignore_missing()
  File "/usr/lib/python3.10/site-packages/unifi_protect_backup/missing_event_checker.py", line 125, in ignore_missing
    wanted_events = await self._get_missing_events()
TypeError: object async_generator can't be used in 'await' expression
Traceback (most recent call last):
  File "/usr/bin/unifi-protect-backup", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/unifi_protect_backup/cli.py", line 209, in main
    run(event_listener.start(), stop_on_unhandled_errors=True)
  File "/usr/lib/python3.10/site-packages/aiorun.py", line 371, in run
    raise pending_exception_to_raise
  File "/usr/lib/python3.10/site-packages/aiorun.py", line 219, in new_coro
    await coro
  File "/usr/lib/python3.10/site-packages/unifi_protect_backup/unifi_protect_backup_core.py", line 270, in start
    await missing.ignore_missing()
  File "/usr/lib/python3.10/site-packages/unifi_protect_backup/missing_event_checker.py", line 125, in ignore_missing
    wanted_events = await self._get_missing_events()
TypeError: object async_generator can't be used in 'await' expression
ep1cman commented 1 year ago

I have pushed a fix for this, it will be included in the next release

Ik-12 commented 1 year ago

Wow, many thanks for a scary fast fix!