Skip to content

Commit 7ab345e

Browse files
author
Christopher Doris
committed
improve input hook [skip ci]
1 parent 6284581 commit 7ab345e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/compat/gui.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,20 @@ end
168168

169169
function _python_input_hook()
170170
try
171-
while true
172-
yield()
173-
@static if Sys.iswindows()
171+
@static if Sys.iswindows()
172+
# on windows, we can call yield in a loop because _kbhit() lets us know
173+
# when to stop
174+
while true
175+
yield()
174176
if ccall(:_kbhit, Cint, ()) != 0
175177
break
176178
end
179+
sleep(0.01)
177180
end
178-
sleep(0.001)
181+
else
182+
# on other platforms, if readline is enabled, the input hook is called
183+
# repeatedly so the loop is not required
184+
yield()
179185
end
180186
catch
181187
return Cint(1)

0 commit comments

Comments
 (0)