# REPL and mainloop

**URL:** <https://discourse.julialang.org/t/repl-and-mainloop/35699>\
**Category:** Internals & Design\
**Created:** [March 7, 2020, 9:20pm UTC](https://discourse.julialang.org/t/repl-and-mainloop/35699 "2020-03-07T21:20:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobias.knopp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobias.knopp/32/7551_2.png) [@tobias.knopp](https://discourse.julialang.org/u/tobias.knopp)\
**Post date:** [March 7, 2020, 9:20pm UTC](https://discourse.julialang.org/t/repl-and-mainloop/35699/1 "2020-03-07T21:20:34Z")

</div>

I have been thinking a little bit about the issue that Gtk makes the REPL sluggish on windows and from my perspective this points at a little bit more general problem: How should one integrate an external mainloop with the REPL?

For context: If one runs a Gtk program in Python / C / … the last statement is a call to `Gtk.main()`, which is blocking and gives control to the mainloop. So in theory we could do the same and would be done.

But if we think about things like a plotting window one is actually interested in keeping the REPL alive and still allow the UI to render. An example here is Winston.jl. My question now is somewhat: Has someone an idea howto solve this properly? Is this something `Gtk.jl` can actually handle or is this a job for the REPL code? One rough idea would be to allow that the REPL runs on a different thread while the main thread runs the Gtk mainloop. What currently happens can be seen here:  
[https://github.com/JuliaGraphics/Gtk.jl/blob/e9127e73466e4f348adc0ee09c0eb50120edb934/src/Gtk.jl#L132](https://github.com/JuliaGraphics/Gtk.jl/blob/e9127e73466e4f348adc0ee09c0eb50120edb934/src/Gtk.jl#L132)

So a task is created and seems to compete with the REPL.
