# Sync/keepalive for Blink.jl/Interact.jl?

**URL:** <https://discourse.julialang.org/t/sync-keepalive-for-blink-jl-interact-jl/21393>\
**Category:** General Usage\
**Tags:** gui\
**Created:** [March 2, 2019, 2:41pm UTC](https://discourse.julialang.org/t/sync-keepalive-for-blink-jl-interact-jl/21393 "2019-03-02T14:41:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlhetland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlhetland/32/283_2.png) [@mlhetland](https://discourse.julialang.org/u/mlhetland)\
**Post date:** [March 2, 2019, 2:41pm UTC](https://discourse.julialang.org/t/sync-keepalive-for-blink-jl-interact-jl/21393/1 "2019-03-02T14:41:58Z")

</div>

I’m sure I just haven’t been good enough at reading the docs/source, but I can’t seem to find any obviously canonical way of using Blink.jl without having it quit immediately. I mean, I could use it from the REPL, but other than that? If I run a Julia program such as, say, one based on a simple [Interact example](https://juliagizmos.github.io/Interact.jl/latest/tutorial/), i.e.,

```julia
using Interact, Blink
ui = button()
w = Window()
body!(w, ui)

```

then that runs just fine, setting up the window properly … and then the program quits. If I add, say, an infinite loop or `read(stdin)` or something at the end, things work as they should, but surely there must be a better way of doing this? (Is there, for example, a process I could wait for, or something?) I’m assuming not everyone is using Blink from the REPL…?

I’m sorry for probably missing something obvious, here :-\>

---

<div class="post-metadata">

**Author:** ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)\
**Post date:** [March 2, 2019, 3:09pm UTC](https://discourse.julialang.org/t/sync-keepalive-for-blink-jl-interact-jl/21393/2 "2019-03-02T15:09:06Z")

</div>

Maybe there is a better way, but heres your infinite loop…

```julia
while window.content.sock.state == WebSockets.ReadyState(1) 
       sleep(0.1)
end

```

---

<div class="post-metadata">

**Author:** ![mlhetland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlhetland/32/283_2.png) [@mlhetland](https://discourse.julialang.org/u/mlhetland)\
**Post date:** [March 2, 2019, 3:11pm UTC](https://discourse.julialang.org/t/sync-keepalive-for-blink-jl-interact-jl/21393/3 "2019-03-02T15:11:36Z")

</div>

Thanks. I’d sort of hope there’d be a better way :-}

---

<div class="post-metadata">

**Author:** ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)\
**Post date:** [March 2, 2019, 3:16pm UTC](https://discourse.julialang.org/t/sync-keepalive-for-blink-jl-interact-jl/21393/4 "2019-03-02T15:16:18Z")

</div>

Me too. I use that in a context where I have the loop running anyway from a package function in a REPL session, and just need to check the window is still there.

I haven’t actually tried to run it from a script.

---

<div class="post-metadata">

**Author:** ![mlhetland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlhetland/32/283_2.png) [@mlhetland](https://discourse.julialang.org/u/mlhetland)\
**Post date:** [April 6, 2020, 2:48pm UTC](https://discourse.julialang.org/t/sync-keepalive-for-blink-jl-interact-jl/21393/5 "2020-04-06T14:48:19Z")

</div>

I couldn’t find any solutions to this, still … maybe I missed something? (If not, I might look into solving the issue, I guess.)

---

<div class="post-metadata">

**Author:** ![mlhetland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlhetland/32/283_2.png) [@mlhetland](https://discourse.julialang.org/u/mlhetland)\
**Post date:** [April 6, 2020, 8:42pm UTC](https://discourse.julialang.org/t/sync-keepalive-for-blink-jl-interact-jl/21393/6 "2020-04-06T20:42:50Z")

</div>

A possible semi-solution:

```julia
using Blink
window = Window()
# …
success(window.shell.proc)

```

Still digging into the innards (could be added to the `Blink.jl` API, perhaps), but beyond that, it also produces an error, as the Julia side seems to keep parsing bytes from Electron, even after you quit it:

```nohighlight
Unexpected end of input
 ...when parsing byte with value '0'
Stacktrace:

```

---

<div class="post-metadata">

**Author:** ![mlhetland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlhetland/32/283_2.png) [@mlhetland](https://discourse.julialang.org/u/mlhetland)\
**Post date:** [April 7, 2020, 6:14pm UTC](https://discourse.julialang.org/t/sync-keepalive-for-blink-jl-interact-jl/21393/7 "2020-04-07T18:14:31Z")

</div>

It seems like Electron.jl is more amenable to this approach (and I don’t really need the extra functionality of Blink, I think):

```julia
using Electron
window = Window()
# …
success(window.app.proc)

```

Or one could use, say:

```julia
success(Electron.default_application().proc)

```

Or … `success` would only make sense once other stuff has already been set up, so there would already be at least one application – so one could use:

```julia
success.(app.proc for app in applications())

```

Would be nice to avoid digging inside `Application`, but … 🤷‍♂️
