X Tutup
Skip to content

Commit 4442a75

Browse files
Search for import completion modules in idle generator
A different technique that amygdalama and I talked about, but required modifications to curtsies: an idle function like cli.py uses. I pulled from amygdalama's repo because I thought we would use that code, and it will be useful when we add Windows support, but it's not necessary right now.
1 parent 04a14d7 commit 4442a75

File tree

4 files changed

+4
-18
lines changed

4 files changed

+4
-18
lines changed

bpython/curtsies.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from bpython.curtsiesfrontend.coderunner import SystemExitFromCodeGreenlet
1616
from bpython import args as bpargs
1717
from bpython.translations import _
18+
from bpython.importcompletion import find_iterator
1819

1920
def main(args=None, locals_=None, banner=None):
2021
config, options, exec_args = bpargs.parse(args, (
@@ -78,7 +79,7 @@ def process_event(e):
7879
process_event(paste)
7980

8081
while True:
81-
process_event(tc.get_event())
82+
process_event(tc.get_event(idle=find_iterator))
8283

8384
if __name__ == '__main__':
8485
sys.exit(main())

bpython/curtsiesfrontend/repl.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ def smarter_request_refresh():
220220

221221
self.width = None # will both be set by a window resize event
222222
self.height = None
223-
self.start_background_tasks()
224223

225224
def __enter__(self):
226225
self.orig_stdout = sys.stdout
@@ -236,18 +235,6 @@ def __exit__(self, *args):
236235
sys.stdout = self.orig_stdout
237236
sys.stderr = self.orig_stderr
238237

239-
def start_background_tasks(self):
240-
"""starts tasks that should run on startup in the background"""
241-
242-
def importcompletion_thread():
243-
#TODO use locks or something to avoid error on import completion right at startup
244-
while importcompletion.find_coroutine(): # returns None when fully initialized
245-
pass
246-
247-
t = threading.Thread(target=importcompletion_thread)
248-
t.daemon = True
249-
t.start()
250-
251238
def clean_up_current_line_for_exit(self):
252239
"""Called when trying to exit to prep for final paint"""
253240
logging.debug('unhighlighting paren for exit')
@@ -946,6 +933,7 @@ def request_refresh():
946933
r.width = 50
947934
r.height = 10
948935
while True:
936+
[_ for _ in importcompletion.find_iterator]
949937
r.dumb_print_output()
950938
r.dumb_input(refreshes)
951939

bpython/importcompletion.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ def complete(line, cw):
5353
if not cw:
5454
return None
5555

56-
if not fully_loaded:
57-
return []
58-
5956
tokens = line.split()
6057
if tokens[0] not in ['from', 'import']:
6158
return None

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def initialize_options(self):
153153
'pygments'
154154
],
155155
extras_require = {
156-
'curtsies': ['curtsies>=0.0.27', 'greenlet'],
156+
'curtsies': ['curtsies>=0.0.28', 'greenlet'],
157157
'urwid' : ['urwid']
158158
},
159159
tests_require = ['mock'],

0 commit comments

Comments
 (0)
X Tutup