Help with julia script

Hello,

I’m having a strange issue on one of my julia scripts. It clearly completes to the end, but doesn’t exit the script.

The last two lines of the script are the following.

println("all complete")
exit()

I can see the message “all complete” but the script doesn’t exit back to the command line. Any ideas how to debug what could be holding the script open?

Can you give us a more complete example ?
I did something very naive on a script run.jl:

a = 1 + 1
println("all complete")
exit()

and on terminal everything works well:

(base) PC@user:~$ julia run.jl 
all complete
(base) PC@user:~$

It’s a large script, but I’m guessing the problem is with the ODBC module that I’m using in this script. I’ve had experience before that if the ODBC connection is opened, but for some reason, it’s not disconnected, then the session hangs when trying to exit.

Since it’s not possible for me to pass the entire script with all of the custom database connections, I’m more looking suggestions on how to debug this.

For now, I’ll try to simulate the portion that connects to the database through ODBC and remove the actual connection to see if that allow the script to terminate.

Yes, it looks like the problem is with this old issue on ODBC. If I remove this portion from the script, it exits correctly. So there must be something causing the ODBC disconnect statement from being executed.

https://github.com/JuliaDatabases/ODBC.jl/issues/172

EDIT: I found why this was not disconnecting. I had the disconnect command in the finally block of a try/finally block. I had forgotten that try/finally blocks have separate scope (which I really cannot understand…)

I don’t think the exit() is even necessary? I thought that was strictly to leave the REPL - I’ve written a bunch of scripts and have never used that function (they end and return the command prompt fine).