Repository: Flexget/Flexget

Issue:
Error on scheduler: Only timezones from the pytz library are supported
### Steps to reproduce:
- Step 1: `flexget -L verbose daemon start`

#### Config:

```yaml
schedules:
  - tasks: ['some-task']
    interval:
      hours: 1
```
  
#### Backtrace:

```
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/__init__.py", line 44, in main
    manager.start()
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/manager.py", line 383, in start
    self.handle_cli()
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/manager.py", line 409, in handle_cli
    self.daemon_command(command_options)
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/manager.py", line 506, in daemon_command
    run_daemon()
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/manager.py", line 487, in run_daemon
    fire_event('manager.daemon.started', self)
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/event.py", line 109, in fire_event
    result = event(*args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/event.py", line 20, in __call__
    return self.func(*args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/components/scheduler/scheduler.py", line 126, in setup_scheduler
    scheduler = BackgroundScheduler(
  File "/home/pi/.local/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 87, in __init__
    self.configure(gconfig, **options)
  File "/home/pi/.local/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 126, in configure
    self._configure(config)
  File "/home/pi/.local/lib/python3.9/site-packages/apscheduler/schedulers/background.py", line 29, in _configure
    super(BackgroundScheduler, self)._configure(config)
  File "/home/pi/.local/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 697, in _configure
    self.timezone = astimezone(config.pop('timezone', None)) or get_localzone()
  File "/home/pi/.local/lib/python3.9/site-packages/apscheduler/util.py", line 93, in astimezone
    raise TypeError('Only timezones from the pytz library are supported')
TypeError: Only timezones from the pytz library are supported
```

### Additional information:

- FlexGet version: 3.5.2
- Python version: 3.9.2
- Installation method:
- Using daemon (yes/no): yes

It seems to have started after https://github.com/Flexget/Flexget/pull/3453 that change the timezone argument to a non-pytz compatible object.
Error on scheduler: Only timezones from the pytz library are supported
### Steps to reproduce:
- Step 1: `flexget -L verbose daemon start`

#### Config:

```yaml
schedules:
  - tasks: ['some-task']
    interval:
      hours: 1
```
  
#### Backtrace:

```
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/__init__.py", line 44, in main
    manager.start()
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/manager.py", line 383, in start
    self.handle_cli()
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/manager.py", line 409, in handle_cli
    self.daemon_command(command_options)
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/manager.py", line 506, in daemon_command
    run_daemon()
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/manager.py", line 487, in run_daemon
    fire_event('manager.daemon.started', self)
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/event.py", line 109, in fire_event
    result = event(*args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/event.py", line 20, in __call__
    return self.func(*args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/flexget/components/scheduler/scheduler.py", line 126, in setup_scheduler
    scheduler = BackgroundScheduler(
  File "/home/pi/.local/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 87, in __init__
    self.configure(gconfig, **options)
  File "/home/pi/.local/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 126, in configure
    self._configure(config)
  File "/home/pi/.local/lib/python3.9/site-packages/apscheduler/schedulers/background.py", line 29, in _configure
    super(BackgroundScheduler, self)._configure(config)
  File "/home/pi/.local/lib/python3.9/site-packages/apscheduler/schedulers/base.py", line 697, in _configure
    self.timezone = astimezone(config.pop('timezone', None)) or get_localzone()
  File "/home/pi/.local/lib/python3.9/site-packages/apscheduler/util.py", line 93, in astimezone
    raise TypeError('Only timezones from the pytz library are supported')
TypeError: Only timezones from the pytz library are supported
```

### Additional information:

- FlexGet version: 3.5.2
- Python version: 3.9.2
- Installation method:
- Using daemon (yes/no): yes

It seems to have started after https://github.com/Flexget/Flexget/pull/3453 that change the timezone argument to a non-pytz compatible object.


Discussion:
It looks like maybe apscheduler handles setting the timezone to the local zone itself now, maybe we can just pull that argument out of the initialization of the scheduler...
It looks like maybe apscheduler handles setting the timezone to the local zone itself now, maybe we can just pull that argument out of the initialization of the scheduler...

Resolving patch:
diff --git a/flexget/components/scheduler/scheduler.py b/flexget/components/scheduler/scheduler.py
--- a/flexget/components/scheduler/scheduler.py
+++ b/flexget/components/scheduler/scheduler.py
@@ -1,4 +1,3 @@
-import datetime
 import hashlib
 import logging
 import os
@@ -126,7 +125,6 @@ def setup_scheduler(manager):
     scheduler = BackgroundScheduler(
         jobstores=jobstores,
         job_defaults=job_defaults,
-        timezone=datetime.datetime.now().astimezone().tzinfo,
     )
     setup_jobs(manager)
 


Test patch: