Skip to content

Commit 11d63cc

Browse files
committed
Require urwid >= 1.0
1 parent b6494ff commit 11d63cc

2 files changed

Lines changed: 2 additions & 34 deletions

File tree

bpython/urwid.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -95,39 +95,7 @@ def buildProtocol(self, addr):
9595
# If Twisted is not available urwid has no TwistedEventLoop attribute.
9696
# Code below will try to import reactor before using TwistedEventLoop.
9797
# I assume TwistedEventLoop will be available if that import succeeds.
98-
if urwid.VERSION < (1, 0, 0) and hasattr(urwid, "TwistedEventLoop"):
99-
100-
class TwistedEventLoop(urwid.TwistedEventLoop):
101-
"""TwistedEventLoop modified to properly stop the reactor.
102-
103-
urwid 0.9.9 and 0.9.9.1 crash the reactor on ExitMainLoop instead
104-
of stopping it. One obvious way this breaks is if anything used
105-
the reactor's thread pool: that thread pool is not shut down if
106-
the reactor is not stopped, which means python hangs on exit
107-
(joining the non-daemon threadpool threads that never exit). And
108-
the default resolver is the ThreadedResolver, so if we looked up
109-
any names we hang on exit. That is bad enough that we hack up
110-
urwid a bit here to exit properly.
111-
"""
112-
113-
def handle_exit(self, f):
114-
def wrapper(*args, **kwargs):
115-
try:
116-
return f(*args, **kwargs)
117-
except urwid.ExitMainLoop:
118-
# This is our change.
119-
self.reactor.stop()
120-
except:
121-
# This is the same as in urwid.
122-
# We are obviously not supposed to ever hit this.
123-
print(sys.exc_info())
124-
self._exc_info = sys.exc_info()
125-
self.reactor.crash()
126-
127-
return wrapper
128-
129-
else:
130-
TwistedEventLoop = getattr(urwid, "TwistedEventLoop", None)
98+
TwistedEventLoop = getattr(urwid, "TwistedEventLoop", None)
13199

132100

133101
class StatusbarEdit(urwid.Edit):

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ install_requires =
3535
[options.extras_require]
3636
clipboard = pyperclip
3737
jedi = jedi >= 0.16
38-
urwid = urwid < 3.0
38+
urwid = urwid >=1.0,< 3.0
3939
watch = watchdog
4040

4141
[options.entry_points]

0 commit comments

Comments
 (0)