Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when running without timezone info #1983

Closed
bjornfor opened this issue Nov 2, 2022 · 9 comments
Closed

Crash when running without timezone info #1983

bjornfor opened this issue Nov 2, 2022 · 9 comments

Comments

@bjornfor
Copy link

bjornfor commented Nov 2, 2022

Describe the bug
When running without timezone info, bazarr falls back to UTC (good) but then crashes soon after (bad):

machine # [    8.785390] systemd[1]: Startup finished in 2.159s (kernel) + 6.625s (userspace) = 8.785s.
machine # [   12.053079] bazarr[810]: /nix/store/9i51lw05qqric348558w7hik57a1fv54-bazarr-1.1.1/share/bazarr-1.1.1/bazarr/../libs/tzlocal/unix.py:177: UserWarning: Can not find any timezone configuration, defaulting to UTC.
machine # [   12.054037] bazarr[810]:   warnings.warn("Can not find any timezone configuration, defaulting to UTC.")
machine # [   12.055025] bazarr[810]: Traceback (most recent call last):
machine # [   12.055398] bazarr[810]:   File "/nix/store/9i51lw05qqric348558w7hik57a1fv54-bazarr-1.1.1/share/bazarr-1.1.1/bazarr/../libs/apscheduler/util.py", line 166, in convert_to_datetime
machine # [   12.056555] bazarr[810]:     return tz.localize(datetime_, is_dst=None)
machine # [   12.057033] bazarr[810]: AttributeError: 'datetime.timezone' object has no attribute 'localize'
machine # [   12.057461] bazarr[810]: During handling of the above exception, another exception occurred:
machine # [   12.057936] bazarr[810]: Traceback (most recent call last):
machine # [   12.058229] bazarr[810]:   File "/nix/store/9i51lw05qqric348558w7hik57a1fv54-bazarr-1.1.1/share/bazarr-1.1.1/bazarr/main.py", line 25, in <module>
machine # [   12.059062] bazarr[810]:     from app.signalr_client import sonarr_signalr_client, radarr_signalr_client  # noqa E402
machine # [   12.059809] bazarr[810]:   File "/nix/store/9i51lw05qqric348558w7hik57a1fv54-bazarr-1.1.1/share/bazarr-1.1.1/bazarr/app/signalr_client.py", line 23, in <module>
machine # [   12.060855] bazarr[810]:     from .scheduler import scheduler
machine # [   12.061412] bazarr[810]:   File "/nix/store/9i51lw05qqric348558w7hik57a1fv54-bazarr-1.1.1/share/bazarr-1.1.1/bazarr/app/scheduler.py", line 285, in <module>
machine # [   12.062622] bazarr[810]:     scheduler = Scheduler()
machine # [   12.063272] bazarr[810]:   File "/nix/store/9i51lw05qqric348558w7hik57a1fv54-bazarr-1.1.1/share/bazarr-1.1.1/bazarr/app/scheduler.py", line 59, in __init__
machine # [   12.064326] bazarr[810]:     self.update_configurable_tasks()
machine # [   12.064833] bazarr[810]:   File "/nix/store/9i51lw05qqric348558w7hik57a1fv54-bazarr-1.1.1/share/bazarr-1.1.1/bazarr/app/scheduler.py", line 71, in update_configurable_tasks
machine # [   12.066026] bazarr[810]:     self.__randomize_interval_task()
machine # [   12.072812] bazarr[810]:   File "/nix/store/9i51lw05qqric348558w7hik57a1fv54-bazarr-1.1.1/share/bazarr-1.1.1/bazarr/app/scheduler.py", line 278, in __randomize_interval_task
machine # [   12.073600] bazarr[810]:     self.aps_scheduler.modify_job(job.id, next_run_time=datetime.now() + timedelta(seconds=randrange(job.trigger.interval.total_seconds()*0.75, job.trigger.interval.total_seconds())))
machine # [   12.074525] bazarr[810]:   File "/nix/store/9i51lw05qqric348558w7hik57a1fv54-bazarr-1.1.1/share/bazarr-1.1.1/bazarr/../libs/apscheduler/schedulers/base.py", line 489, in modify_job
machine # [   12.075495] bazarr[810]:     job._modify(**changes)
machine # [   12.075867] bazarr[810]:   File "/nix/store/9i51lw05qqric348558w7hik57a1fv54-bazarr-1.1.1/share/bazarr-1.1.1/bazarr/../libs/apscheduler/job.py", line 225, in _modify
machine # [   12.076717] bazarr[810]:     approved['next_run_time'] = convert_to_datetime(value, self._scheduler.timezone,
machine # [   12.081875] bazarr[810]:   File "/nix/store/9i51lw05qqric348558w7hik57a1fv54-bazarr-1.1.1/share/bazarr-1.1.1/bazarr/../libs/apscheduler/util.py", line 168, in convert_to_datetime
machine # [   12.082836] bazarr[810]:     raise TypeError(
machine # [   12.083147] bazarr[810]: TypeError: Only pytz timezones are supported (need the localize() and normalize() methods)
machine # [   13.301045] bazarr[808]: Bazarr starting...
machine # [   13.301531] bazarr[808]: Bazarr exited.
machine # [   13.330651] systemd[1]: bazarr.service: Deactivated successfully.
machine # [   13.331121] systemd[1]: bazarr.service: Consumed 3.975s CPU time, no IO, no IP traffic.

(Well, apparently it "succeeds" -- that's another issue.)

To Reproduce
Steps to reproduce the behavior:

  1. In NixOS, use this config: { services.bazarr.enable = true; }
  2. See error

Expected behavior
bazarr should not crash.

The issue can be worked around by adding { time.timeZone = "UTC"; }. But IMHO, given that bazarr says it's using UTC when no info was given, explicitly setting the timezone to UTC should be a NOP right?

Software (please complete the following information):

  • Bazarr: 1.1.1 and 1.1.2.
  • OS: NixOS 22.05
@morpheus65535
Copy link
Owner

I've just updated vendored apscheduler in upcoming beta. Can you test and confirmif you still have the issue?

@bjornfor
Copy link
Author

bjornfor commented Nov 7, 2022

  • development (4f06020): gets past the startup error, but the NixOS test fails soon after when trying to access the service: curl --fail http://localhost:42069/ (the test uses an arbitrary port) -> curl: (22) The requested URL returned error: 500
  • master (7034695): TypeError: Only pytz timezones are supported (need the localize() and normalize() methods)
  • Latest beta (v1.1.3-beta.12.zip): TypeError: Only pytz timezones are supported (need the localize() and normalize() methods)

I guess we can say that the development branch has fixed it, but now I need to figure out why it fails with http error 500.

@bjornfor
Copy link
Author

bjornfor commented Nov 7, 2022

[...] but now I need to figure out why it fails with http error 500.

With --debug option:

2022-11-07 23:33:53,267 - app.app                          (7f774cccc640) :  ERROR (app:1741) - Exception on / [GET]
Traceback (most recent call last):
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/../libs/flask/app.py", line 2525, in wsgi_app
    response = self.full_dispatch_request()
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/../libs/flask/app.py", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/../libs/flask_restx/api.py", line 675, in error_router
    return original_handler(e)
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/../libs/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/../libs/flask/app.py", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/../libs/flask/app.py", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/app/ui.py", line 88, in catch_all
    return render_template("index.html", BAZARR_SERVER_INJECT=inject, baseUrl=template_url)
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/../libs/flask/templating.py", line 146, in render_template
    template = app.jinja_env.get_or_select_template(template_name_or_list)
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/../libs/jinja2/environment.py", line 1081, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/../libs/jinja2/environment.py", line 1010, in get_template
    return self._load_template(name, globals)
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/../libs/jinja2/environment.py", line 969, in _load_template
    template = self.loader.load(self, name, self.make_globals(globals))
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/../libs/jinja2/loaders.py", line 126, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/../libs/flask/templating.py", line 62, in get_source
    return self._get_source_fast(environment, template)
  File "/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/bazarr/../libs/flask/templating.py", line 98, in _get_source_fast
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: index.html

Does v1.1.2+ require packaging changes? Or are there some resources missing from git snapshots?

@bjornfor
Copy link
Author

bjornfor commented Nov 7, 2022

index.html is packaged, but for some reason not found:

$ find /nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/ -name index.html
/nix/store/5va5d3i7jkk8i9cf0arwhky54qmkqv08-bazarr-1.1.2-dev/share/bazarr/frontend/index.html

@bjornfor
Copy link
Author

bjornfor commented Nov 7, 2022

It's looking for the template in .../frontend/build (which doesn't exist):

$ ./result/bin/bazarr --config bazarr_config_dir/ --no-update True
Bazarr starting...
template_folder: /nix/store/9fwmkgpkvs8ysdpd69jvh6lb2xfy5afd-bazarr-1.1.2-dev/share/bazarr/frontend/build     <--- I added this printout
2022-11-07 23:47:54,732 - root                             (7f9b014df740) :  INFO (server:64) - BAZARR is started and waiting for request on http://0.0.0.0:6767
^CBazarr exited.

$ ls -l /nix/store/9fwmkgpkvs8ysdpd69jvh6lb2xfy5afd-bazarr-1.1.2-dev/share/bazarr/frontend/build
ls: cannot access '/nix/store/9fwmkgpkvs8ysdpd69jvh6lb2xfy5afd-bazarr-1.1.2-dev/share/bazarr/frontend/build': No such file or directory

[...] are there some resources missing from git snapshots?

I think so. Looking at the beta release, it has .../frontend/build directory.

So I guess this issue is fixed in the development branch, but I'm unable to fully test it due to missing resources.

@morpheus65535
Copy link
Owner

You can use the frontend from latest beta release asset with dev Bazarr. If you wait until tomorrow, a new beta release with assets will be released.

@bjornfor
Copy link
Author

bjornfor commented Nov 7, 2022

Ok, thanks!

@bjornfor
Copy link
Author

I tested version 1.1.3-beta.16 -- it passed 🎉

@morpheus65535
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants