# Is there a "gap" between acquire and try in the acquire-try-finally idiom?

**URL:** https://discourse.julialang.org/t/is-there-a-gap-between-acquire-and-try-in-the-acquire-try-finally-idiom/96224
**Category:** General Usage
**Tags:** exception
**Created:** [March 17, 2023, 5:58am UTC](https://discourse.julialang.org/t/is-there-a-gap-between-acquire-and-try-in-the-acquire-try-finally-idiom/96224 "2023-03-17T05:58:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ettersi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ettersi/32/6829_2.png) [@ettersi](https://discourse.julialang.org/u/ettersi)
#### Post date: [March 17, 2023, 5:58am UTC](https://discourse.julialang.org/t/is-there-a-gap-between-acquire-and-try-in-the-acquire-try-finally-idiom/96224/1 "2023-03-17T05:58:11Z")

</div>

The prime motivation for `finally` clauses is to guarantee clean-up of resources like open files, locks, etc. For example, the [Julia docs on `finally` clauses](https://docs.julialang.org/en/v1/manual/control-flow/#finally-Clauses) present the following example.

```julia
f = open("file")
try
    # operate on file f
finally
    close(f)
end

```

In codes like this, there is some syntactic “gap” between returning from `open()` and entering the `try` block. This raises the question: does the language guarantee that no exception can be thrown in this gap? It’s clear that nothing “internal” can throw an exception (there simply isn’t anything which could do that), but what about e.g. interrupts?
