# Add println in Julia code and reload, can this be done? (likely bug in WeakKeyDict)

**URL:** <https://discourse.julialang.org/t/add-println-in-julia-code-and-reload-can-this-be-done-likely-bug-in-weakkeydict/30564>\
**Category:** General Usage\
**Created:** [October 31, 2019, 10:23pm UTC](https://discourse.julialang.org/t/add-println-in-julia-code-and-reload-can-this-be-done-likely-bug-in-weakkeydict/30564 "2019-10-31T22:23:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![swissr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/swissr/32/208_2.png) [@swissr](https://discourse.julialang.org/u/swissr)\
**Post date:** [October 31, 2019, 10:23pm UTC](https://discourse.julialang.org/t/add-println-in-julia-code-and-reload-can-this-be-done-likely-bug-in-weakkeydict/30564/1 "2019-10-31T22:23:02Z")

</div>

Context: The following command causes a dead-lock in 1.4.0-DEV.407 (2019-10-31) and likely also in 1.3. It works fine in 1.03 and 1.2.

```
x = WeakKeyDict(:a1 => 4)
push!(x, :a2 => 2) # WARNING: deadlock here

```

I thought I could add some `println` statements in `setindex!`in ‘weakkeydict.jl’ and then `include` the modified file. Not unexpectedly this didn’t work but I wonder if there is a possibility to change Julia code and then take into account the changes? I rebuild Julia with the `make` command which worked but took a long time.

(Regarding dead-lock: it hangs when executing [https://github.com/JuliaLang/julia/blob/4f649c207a97104d7eb1b9bc3e486d39522f4a5e/base/weakkeydict.jl#L81](https://github.com/JuliaLang/julia/blob/4f649c207a97104d7eb1b9bc3e486d39522f4a5e/base/weakkeydict.jl#L81))

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [October 31, 2019, 10:24pm UTC](https://discourse.julialang.org/t/add-println-in-julia-code-and-reload-can-this-be-done-likely-bug-in-weakkeydict/30564/2 "2019-10-31T22:24:45Z")

</div>

See [https://github.com/timholy/Revise.jl](https://github.com/timholy/Revise.jl). For changing Julia’s base code you’d need to say `Revise.track(Base)` for any changes to take effect.

---

<div class="post-metadata">

**Author:** ![swissr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/swissr/32/208_2.png) [@swissr](https://discourse.julialang.org/u/swissr)\
**Post date:** [October 31, 2019, 10:32pm UTC](https://discourse.julialang.org/t/add-println-in-julia-code-and-reload-can-this-be-done-likely-bug-in-weakkeydict/30564/3 "2019-10-31T22:32:50Z")

</div>

Incredible. Worked perfectly. Didn’t think that Revise goes that far. Thanks a lot!

* * *

Regarding dead-lock. I will make an issue in github soon. [Edit: here is a PR [https://github.com/JuliaLang/julia/pull/33756](https://github.com/JuliaLang/julia/pull/33756). As mentioned, I’m not 100 % sure about the proposed solution]
