insanum / sncli

Simplenote CLI
MIT License
396 stars 34 forks source link

sncli crashes with TypeError: unorderable types: function() < function() #35

Closed NewMexicoKid closed 5 years ago

NewMexicoKid commented 7 years ago

Problem:

Environment:

Error:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 911, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 859, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.4/site-packages/simplenote_cli/notes_db.py", line 632, in sync_worker
    self.sync_now(do_server_sync)
  File "/usr/lib/python3.4/site-packages/simplenote_cli/notes_db.py", line 625, in sync_now
    full_sync=True if not self.last_sync else False)
  File "/usr/lib/python3.4/site-packages/simplenote_cli/notes_db.py", line 428, in sync_notes
    self.log("Starting full sync")
  File "/usr/lib/python3.4/site-packages/simplenote_cli/sncli.py", line 258, in log
    self.log_timeout, None)
  File "/usr/lib/python3.4/site-packages/urwid/main_loop.py", line 165, in set_alarm_in
    return self.event_loop.alarm(sec, cb)
  File "/usr/lib/python3.4/site-packages/urwid/main_loop.py", line 604, in alarm
    heapq.heappush(self._alarms, (tm, callback))
TypeError: unorderable types: function() < function()
samuelallan72 commented 7 years ago

Ok, so it happening 2-3 seconds after opening is because it's happening when it tries to start a full sync (once it's logged in). I can't see what could be causing that from sncli.

It looks like the problem is that self._alarms in urwid somehow has functions as items in it, so when it uses heapq to add (tm, callback) (a tuple), it crashes. What version of urwid do you have?

NewMexicoKid commented 7 years ago

Thanks for the quick reply.

[~] 504> pip3 freeze
requests==2.13.0
sncli==0.1.3
urwid==1.3.1
samuelallan72 commented 7 years ago

@NewMexicoKid Unfortunately I can't reproduce the crash. I tested it with python 3.4.5 and the urwid version you have (which is the latest one anyway). Perhaps it is a windows related problem - in that case I don't have a copy of windows 7 available to test it on, sorry.

Some things you could try:

with open('/path/to/some/log.txt', 'a') as f:
  f.write(str(self._alarms))
NewMexicoKid commented 7 years ago

My .snclirc

[sncli]
cfg_sn_username = ...
cfg_sn_password = ...

# see http://urwid.org/manual/userinput.html for examples of more key combinations
# kb_edit_note = space
# kb_page_down = ctrl f

# note that values must not be quoted
clr_note_focus_bg = light blue

# the EDITOR env variable overrides the value below
cfg_editor = vim

I'm having difficulty locating the python 3.6 for cygwin. There was a github project for building it (for cygwin), but I encountered a fatal error when trying this.

Trying the deletion of ~/.sncli (notes storage folder?). I've added the debug lines you suggested and will report back if/when the issue strikes again. Thanks!

NewMexicoKid commented 7 years ago

It took a day, but sncli crashed with a longer output:

Traceback (most recent call last):
  File "/usr/bin/sncli", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.4/site-packages/simplenote_cli/sncli.py", line 1206, in main
    sncli(sync, verbose, config).gui(key)
  File "/usr/lib/python3.4/site-packages/simplenote_cli/sncli.py", line 1017, in gui
    self.sncli_loop.run()
  File "/usr/lib/python3.4/site-packages/urwid/main_loop.py", line 278, in run
    self._run()
  File "/usr/lib/python3.4/site-packages/urwid/main_loop.py", line 376, in _run
    self.event_loop.run()
  File "/usr/lib/python3.4/site-packages/urwid/main_loop.py", line 682, in run
    """
  File "/usr/lib/python3.4/site-packages/urwid/main_loop.py", line 719, in _loop
    tm, alarm_callback = self._alarms.pop(0)
  File "/usr/lib/python3.4/site-packages/urwid/raw_display.py", line 393, in <lambda>
    event_loop, callback, self.get_available_raw_input())
  File "/usr/lib/python3.4/site-packages/urwid/raw_display.py", line 493, in parse_input
    callback(processed, processed_codes)
  File "/usr/lib/python3.4/site-packages/urwid/main_loop.py", line 403, in _update
    self.process_input(keys)
  File "/usr/lib/python3.4/site-packages/urwid/main_loop.py", line 503, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/usr/lib/python3.4/site-packages/simplenote_cli/sncli.py", line 655, in gui_frame_keypress
    self.ndb.set_note_content(note['localkey'], content)
  File "/usr/lib/python3.4/site-packages/simplenote_cli/notes_db.py", line 333, in set_note_content
    self.log('Note content updated (key={0})'.format(key))
  File "/usr/lib/python3.4/site-packages/simplenote_cli/sncli.py", line 258, in log
    self.log_timeout, None)
  File "/usr/lib/python3.4/site-packages/urwid/main_loop.py", line 165, in set_alarm_in
    return self.event_loop.alarm(sec, cb)
  File "/usr/lib/python3.4/site-packages/urwid/main_loop.py", line 604, in alarm
    """
TypeError: unorderable types: function() < function()

Nothing went to the log file from the debug lines added to urwid/main_loop.py

samuelallan72 commented 7 years ago

:\ Unfortunately that doesn't help much more. The only other thing I can think of is you could pastebin your sncli log file (removing sensitive information first!) for inspection, but I'm afraid that without access to the same platform as you are running it on, I'm not sure how I can help. Perhaps someone else in the community can shed light on what could be causing it.

NewMexicoKid commented 7 years ago

Thanks, Samuel. Here is my pastebin log (with keys and auth and email removed). I tried again to install python 3.6, but the build on Cygwin/Windows 7 is having problems.

samuelallan72 commented 7 years ago

@NewMexicoKid nothing out of the ordinary in the logs I can see. :\

thepith commented 6 years ago

You can fix the error by using the developement version of urwid:

 pip3 install git+https://github.com/urwid/urwid

you might need to uninstall urwid beforehand.

NewMexicoKid commented 6 years ago

Thanks--I'll give it a try.

On Wed, Dec 13, 2017 at 9:54 AM, thepith notifications@github.com wrote:

You can fix the error by using the developement version of urwid:

pip3 install git+https://github.com/urwid/urwid

you might need to uninstall urwid beforehand.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/insanum/sncli/issues/35#issuecomment-351433450, or mute the thread https://github.com/notifications/unsubscribe-auth/ACNE8A4A4RDrApzy7OYEgn0piViqXRZNks5s__NAgaJpZM4L8ify .

-- Tim Yao - the.NewMexicoKid@gmail.com NewMexicoKid@naperwrimo.org mliaisons@naperwrimo.org aka NewMexicoKid at National Novel Writing Month, http://nanowrimo.org http://www.nanowrimo.org co-Municipal Liaison for the Illinois::Naperville region NaperWriMo - http://naperwrimo.org

samuelallan72 commented 5 years ago

I'm going to close this now since it appears to have been an issue in an older version of urwid.