pimutils / khal

:calendar: CLI calendar application
https://lostpackets.de/khal/
MIT License
2.61k stars 205 forks source link

Long ranges tend to crash khal #772

Closed doofy closed 1 year ago

doofy commented 6 years ago

This is more of a question if others can confirm and help specify the problem: I like to enter the birthdays of people as a event with date of their birth. Lets say 1980-01-01. In khal interactive this always leads to long freezes in the UI. I suspect because of the huge range of the start date (1980) to the end date (this year - 2018). Sometimes this crashes khal with:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/khal/ui/__init__.py", line 1300, in start_pane
    loop.run()
  File "/usr/lib/python3.6/site-packages/urwid/main_loop.py", line 286, in run
    self._run()
  File "/usr/lib/python3.6/site-packages/urwid/main_loop.py", line 384, in _run
    self.event_loop.run()
  File "/usr/lib/python3.6/site-packages/urwid/main_loop.py", line 788, in run
    self._loop()
  File "/usr/lib/python3.6/site-packages/urwid/main_loop.py", line 825, in _loop
    self._watch_files[fd]()
  File "/usr/lib/python3.6/site-packages/urwid/raw_display.py", line 404, in <lambda>
    event_loop, callback, self.get_available_raw_input())
  File "/usr/lib/python3.6/site-packages/urwid/raw_display.py", line 502, in parse_input
    callback(processed, processed_codes)
  File "/usr/lib/python3.6/site-packages/urwid/main_loop.py", line 411, in _update
    self.process_input(keys)
  File "/usr/lib/python3.6/site-packages/urwid/main_loop.py", line 511, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/usr/lib/python3.6/site-packages/urwid/wimp.py", line 648, in keypress
    return self._current_widget.keypress(size, key)
  File "/usr/lib/python3.6/site-packages/urwid/container.py", line 1131, in keypress
    return self.body.keypress( (maxcol, remaining), key )
  File "/usr/lib/python3.6/site-packages/urwid/container.py", line 2271, in keypress
    key = w.keypress((mc,) + size[1:], key)
  File "/usr/lib/python3.6/site-packages/khal/ui/editor.py", line 503, in keypress
    return super().keypress(size, key)
  File "/usr/lib/python3.6/site-packages/khal/ui/widgets.py", line 376, in keypress
    key = super().keypress(size, key)
  File "/usr/lib/python3.6/site-packages/urwid/listbox.py", line 999, in keypress
    key = focus_widget.keypress((maxcol,),key)
  File "/usr/lib/python3.6/site-packages/urwid/wimp.py", line 540, in keypress
    self._emit('click')
  File "/usr/lib/python3.6/site-packages/urwid/widget.py", line 460, in _emit
    signals.emit_signal(self, name, self, *args)
  File "/usr/lib/python3.6/site-packages/urwid/signals.py", line 265, in emit
    result |= self._call_callback(callback, user_arg, user_args, args)
  File "/usr/lib/python3.6/site-packages/urwid/signals.py", line 295, in _call_callback
    return bool(callback(*args_to_pass))
  File "/usr/lib/python3.6/site-packages/khal/ui/editor.py", line 487, in save
    self.event.recurring or self.recurrenceeditor.changed,
  File "/usr/lib/python3.6/site-packages/khal/ui/__init__.py", line 726, in update_colors
    self.pane.calendar.original_widget.set_focus_date(new_start)
  File "/usr/lib/python3.6/site-packages/khal/ui/calendarwidget.py", line 649, in set_focus_date
    self.box.set_focus_date(a_day)
  File "/usr/lib/python3.6/site-packages/khal/ui/calendarwidget.py", line 312, in set_focus_date
    self.body.set_focus_date(a_day)
  File "/usr/lib/python3.6/site-packages/khal/ui/calendarwidget.py", line 386, in set_focus_date
    row, column = self.get_date_pos(a_day)
  File "/usr/lib/python3.6/site-packages/khal/ui/calendarwidget.py", line 434, in get_date_pos
    column = self[row].get_date_column(a_day)
IndexError: list index out of range

All in all the handling of this seems partly broken.

lucc commented 6 years ago

Although it is not an answer to your question, you can use vcards to make a birthday calendar. It will not show the birthday of the person prior to their birth :)

I have this calendar in my config:

[calendars]
  [[birthdays]]
    path = ~/.local/share/khard/main
    type = birthdays

Check the docs here.

doofy commented 6 years ago

@lucc thanks! I totally did not see this and will try it out

geier commented 6 years ago

These are basically two problems: a) the long loading times: this is probably due to khal generating all months up to that date instead of reloading, this is currently by design, but performance improvements would obviously great here (for example by throwing away the old calendar and generating a new one at a given date if the new date is far away).

b) sounds like a serious bug, if you can reproduce this, please supply both the first selected date and the one you are jumping to

mb720 commented 3 years ago

I just ran into this when adding a calendar event that repeats yearly.

Steps to reproduce:

Consequently, khal crashes with the following stack trace

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/khal/ui/__init__.py", line 1356, in start_pane
    loop.run()
  File "/usr/lib/python3.9/site-packages/urwid/main_loop.py", line 287, in run
    self._run()
  File "/usr/lib/python3.9/site-packages/urwid/main_loop.py", line 385, in _run
    self.event_loop.run()
  File "/usr/lib/python3.9/site-packages/urwid/main_loop.py", line 790, in run
    self._loop()
  File "/usr/lib/python3.9/site-packages/urwid/main_loop.py", line 827, in _loop
    self._watch_files[fd]()
  File "/usr/lib/python3.9/site-packages/urwid/raw_display.py", line 416, in <lambda>
    wrapper = lambda: self.parse_input(
  File "/usr/lib/python3.9/site-packages/urwid/raw_display.py", line 515, in parse_input
    callback(processed, processed_codes)
  File "/usr/lib/python3.9/site-packages/urwid/main_loop.py", line 412, in _update
    self.process_input(keys)
  File "/usr/lib/python3.9/site-packages/urwid/main_loop.py", line 513, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/usr/lib/python3.9/site-packages/urwid/wimp.py", line 651, in keypress
    return self._current_widget.keypress(size, key)
  File "/usr/lib/python3.9/site-packages/urwid/container.py", line 1135, in keypress
    return self.body.keypress( (maxcol, remaining), key )
  File "/usr/lib/python3.9/site-packages/urwid/container.py", line 2316, in keypress
    key = w.keypress((mc,) + size[1:], key)
  File "/usr/lib/python3.9/site-packages/khal/ui/editor.py", line 527, in keypress
    return super().keypress(size, key)
  File "/usr/lib/python3.9/site-packages/khal/ui/widgets.py", line 376, in keypress
    key = super().keypress(size, key)
  File "/usr/lib/python3.9/site-packages/urwid/listbox.py", line 968, in keypress
    key = focus_widget.keypress((maxcol,),key)
  File "/usr/lib/python3.9/site-packages/urwid/container.py", line 2316, in keypress
    key = w.keypress((mc,) + size[1:], key)
  File "/usr/lib/python3.9/site-packages/urwid/wimp.py", line 543, in keypress
    self._emit('click')
  File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 461, in _emit
    signals.emit_signal(self, name, self, *args)
  File "/usr/lib/python3.9/site-packages/urwid/signals.py", line 265, in emit
    result |= self._call_callback(callback, user_arg, user_args, args)
  File "/usr/lib/python3.9/site-packages/urwid/signals.py", line 295, in _call_callback
    return bool(callback(*args_to_pass))
  File "/usr/lib/python3.9/site-packages/khal/ui/editor.py", line 509, in save
    self._save_callback(
  File "/usr/lib/python3.9/site-packages/khal/ui/__init__.py", line 731, in update_colors
    self.pane.calendar.original_widget.set_focus_date(new_start)
  File "/usr/lib/python3.9/site-packages/khal/ui/calendarwidget.py", line 659, in set_focus_date
    self.box.set_focus_date(a_day)
  File "/usr/lib/python3.9/site-packages/khal/ui/calendarwidget.py", line 311, in set_focus_date
    self.body.set_focus_date(a_day)
  File "/usr/lib/python3.9/site-packages/khal/ui/calendarwidget.py", line 387, in set_focus_date
    row, column = self.get_date_pos(a_day)
  File "/usr/lib/python3.9/site-packages/khal/ui/calendarwidget.py", line 435, in get_date_pos
    column = self[row].get_date_column(a_day)
IndexError: list index out of range

Config:

[default]
  highlight_event_days = True

[calendars]
  [[personal]]
    path = ~/.local/share/calendars/personal

[view]
  theme = light

[locale]
weeknumbers = right
# See https://docs.python.org/3/library/time.html#time.strftime
timeformat = %H:%M
# Used in event list and when editing an event (hit enter twice)
longdateformat = %Y-%m-%d
# Used in event details (select event by hitting enter once)
dateformat = %Y-%m-%d

I'm on Arch Linux 5.12.3 using khal version 0.10.3.

geier commented 1 year ago

this seems to be a duplicate of #1200, which is addressed with #1262