# Inexplicable pause in Julia execution

**URL:** <https://discourse.julialang.org/t/inexplicable-pause-in-julia-execution/79076>\
**Category:** General Usage\
**Created:** [April 6, 2022, 12:06am UTC](https://discourse.julialang.org/t/inexplicable-pause-in-julia-execution/79076 "2022-04-06T00:06:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)\
**Post date:** [April 6, 2022, 12:06am UTC](https://discourse.julialang.org/t/inexplicable-pause-in-julia-execution/79076/1 "2022-04-06T00:06:21Z")

</div>

I have an application that checks for files placed in a certain directory and then processes the files and waits for the next file. Yesterday we fixed a bug and set the program to work again. This morning when I checked the display said it was working on a file, but when I checked the CPU resources, it was at zero. It normally is at about 13% or close to 1 core. I clicked the mouse at random in the terminal running Julia, and seemingly jarred it back to life. Somewhat later it stalled again. Same thing but this time I noticed that it was a right click that jarred it back to life.  
I updated from Julia 1.7.1 to 1.7.2. It seems to be working fine so far.  
This is on a windows 10 computer.  
Has anyone seen this type of behaviour before? Or any hints as to what might be at fault.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [April 6, 2022, 12:40pm UTC](https://discourse.julialang.org/t/inexplicable-pause-in-julia-execution/79076/2 "2022-04-06T12:40:17Z")

</div>

> [@Jake](#):
>
> I clicked the mouse at random in the terminal running Julia, and seemingly jarred it back to life.

Julia doesn’t listen to mouse clicks,\* so this seems just well an _apparent_ random pause/slowness in your Julia program, and it would have continued without you doing anything. I suspect something like an anti-virus program interfering, especially on Windows, maybe something built-in. Your \*own _Julia_ program can listen to the mouse (even in the terminal, on Linux, Windows and macOS, I wasn’t sure possible, I confirmed in Python with “from pynput import mouse”), but if so you could or should know if it did.

There are some exceptions, like in Linux middle clicking might paste text, so it would look like input from the keyboard. Julia would also ignore such for your program, except _maybe_ CTRL-C, unless your program were expecting input.

`*` I’m pretty sure about this, there’s no good reason for Julia or other languages, such as C++ (it neither has any mouse support in its standard library, nor seemingly Python), to do it (Visual Basic might be an exception), by default. I even checked the source code for Julia for “mouse” and I only found emoji/mouse false-alarms:

```julia
    "\\:mouse:" => "🐭",
    "\\:mouse_trap:" => "🪤",

```

FYI: If you DO want to listen to a mouse, there’s seemingly some Julia code available (or you could call Python with the the above mentioned library), so if you suspect your code doing that, you can look up if relevant Julia (or e.g. Python) packages used:

> [@Ever wanted to automate your keyboard and mouse and perform clicks/take screenshots?](https://discourse.julialang.org/t/ever-wanted-to-automate-your-keyboard-and-mouse-and-perform-clicks-take-screenshots/41848):
>
> I could not find any package to automate the keyboard/mouse so I built a wrapper of a Python library using PyCall. This allows you to perform complex key clicks/take screenshots/scroll etc using Julia syntax/arrays etc!!! slight_smile[Repository](https://github.com/SubhadityaMukherjee/autogui.jl) Examples provided in the test [notebook](https://github.com/SubhadityaMukherjee/autogui.jl/blob/master/test/testAndSource.ipynb) [HELP] Every function works when run in a notebook but when I make it into a package I get PyCall errors. Could someone help me fix it? Its the only thing left. ERROR: ArgumentError: ref of NULL PyObject

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [April 6, 2022, 1:02pm UTC](https://discourse.julialang.org/t/inexplicable-pause-in-julia-execution/79076/3 "2022-04-06T13:02:24Z")

</div>

Perhaps something is pausing applications that do not have focus? Are you using a battery saver or something like that?

---

<div class="post-metadata">

**Author:** ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)\
**Post date:** [April 6, 2022, 2:37pm UTC](https://discourse.julialang.org/t/inexplicable-pause-in-julia-execution/79076/4 "2022-04-06T14:37:27Z")

</div>

Thanks for the responses.

This program displays when it is processing a file, and when it is finished it displays that it has waited x seconds since processing the last file. While waiting it goes to sleep using the Julia sleep command. Every 15 s it checks for a new file. If the new file is there it displays that it is processing. If there is not a new file it redisplays the number of seconds it has been waiting and goes back to sleep. If I watch the CPU resources in the task manager I can confirm that it sleeping or processing.

During these anomalies, I was watching the CPU resources in the task manager while the program was in a state where it should have been processing a file. The CPU resources were 0 (or really close). Then with the right mouse click the CPU resources went to 13%. It seemed odd.

The program is essentially a continuous while loop that never terminates by itself. It either terminates with a Ctrl C or by exiting the terminal running the process. Either way a hard kill of the process. The Ctrl C also exits the terminal running the process, somewhat to my chagrin.

It is an industrial Lenova machine, no batteries. I believe it only has the Windows default anti-virus and firewalls. It is a headless machine. I access it by remote desktop connection to an intermediate virtual machine and then TightVNC to this remote machine. So I suppose it is possible that a right mouse click has opportunity to be something different on the remote machine?

Everything ran well after I posted yesterday.

So I gather it could be something weird happening in the communication between computers, a weird interaction between the OS and Julia, or perhaps even some weird hardware issue, or as suggested some very improbable random event.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [April 7, 2022, 8:06am UTC](https://discourse.julialang.org/t/inexplicable-pause-in-julia-execution/79076/5 "2022-04-07T08:06:06Z")

</div>

> [@Jake](#):
>
> it goes to sleep using the Julia sleep command. Every 15 s it checks for a new file.

This would have been good info from the start, likely explaining (in part, of fully because of TightVNC) the “pause”. Maybe you didn’t know this when posting. Also helpful::

> [@Jake](#):
>
> I access it by remote desktop connection to an intermediate virtual machine and then TightVNC to this remote machine.

I suspect there’s some optimization in your setup, likely by TightVNC, to save bandwidth, since these programs are likely made for use of more interactive programs (or with less sleeping). What I found for VNC may apply to it:

> <https://superuser.com/questions/15337/how-can-i-make-vnc-faster/15355#15355>

> Try to use this:
> 
> -snapfb  
> […]
> 
> I had issues with update latency of 10secs +. This flag made this problem completely go away. Don’t know why this answer does not have more upvotes.
