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

npyscreen 4.10.5 does not works on python 3.8 #108

Open
yhojann-cl opened this issue Oct 5, 2020 · 2 comments
Open

npyscreen 4.10.5 does not works on python 3.8 #108

yhojann-cl opened this issue Oct 5, 2020 · 2 comments

Comments

@yhojann-cl
Copy link

yhojann-cl commented Oct 5, 2020

By example:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import npyscreen

class MainForm(npyscreen.FormBaseNew):
    def create(self):
        self.add(npyscreen.BoxTitle, name="BoxTitle")

class MainController(npyscreen.StandardApp):
    def onStart(self):
        self.addForm('MAIN', MainForm, name='Test')

class MainCLS(object):
    def __init__(self):
        mainController = MainController()
        mainController.run()

if __name__ == '__main__':
    MainCLS()

The results:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.1 LTS
Release:	20.04
Codename:	focal
$ python3 --version
Python 3.8.2
$ pip3 install npyscreen
Requirement already satisfied: npyscreen in /home/.../.local/lib/python3.8/site-packages (4.10.5)
$ python3 test.py
Traceback (most recent call last):
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/apNPSApplicationEvents.py", line 16, in get
    yield self.interal_queue.pop()
IndexError: pop from an empty deque

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/apNPSApplicationEvents.py", line 18, in get
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "test.py", line 20, in <module>
    MainCLS()
  File "test.py", line 17, in __init__
    mainController.run()
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/apNPSApplication.py", line 30, in run
    return npyssafewrapper.wrapper(self.__remove_argument_call_main)
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/npyssafewrapper.py", line 41, in wrapper
    wrapper_no_fork(call_function)
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/npyssafewrapper.py", line 97, in wrapper_no_fork
    return_code = call_function(_SCREEN)    
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/apNPSApplication.py", line 25, in __remove_argument_call_main
    return self.main()
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/apNPSApplicationManaged.py", line 172, in main
    self._THISFORM.edit()
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/fm_form_edit_loop.py", line 47, in edit
    self.edit_loop()
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/fm_form_edit_loop.py", line 38, in edit_loop
    self._widgets__[self.editw].edit()
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/wgboxwidget.py", line 150, in edit
    self.entry_widget.edit()
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/wgmultiline.py", line 581, in edit
    self.get_and_use_key_press()
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/wgwidget.py", line 575, in get_and_use_key_press
    return self.try_while_waiting()
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/wgwidget.py", line 560, in try_while_waiting
    self.parent.parentApp._internal_while_waiting()
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/apNPSApplicationEvents.py", line 41, in _internal_while_waiting
    self.process_event_queues(max_events_per_queue=self.max_events_per_queue)
  File "/home/.../.local/lib/python3.8/site-packages/npyscreen/apNPSApplicationEvents.py", line 51, in process_event_queues
    for event in queue.get(maximum=max_events_per_queue):
RuntimeError: generator raised StopIteration
@sur0g
Copy link

sur0g commented Jan 3, 2021

Got this on Ubuntu 20.04 LTS with Python 3.8.
Seems like it's more curses problem that npyscreen by itself (or it's just outdated).
I was able to fix it by wrapping this loop with try block at npyscreen.apNPSApplicationEvents.StandardApp.process_event_queues

    def process_event_queues(self, max_events_per_queue=None):
        for queue in self.event_queues.values():
+            try:
                for event in queue.get(maximum=max_events_per_queue):
                    self.process_event(event)
+            except (RuntimeError, StopIteration):
+                pass

I don't understand the issue's origins and this fix though.

@bartlomiejcieszkowski
Copy link

hit the same error, checked the code:
https://github.com/npcole/npyscreen/blob/master/npyscreen/apNPSApplicationEvents.py#L18
and it looks like its fixed on master for 2 years

the version on pypi is very old

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

No branches or pull requests

3 participants