Sign in to follow this  
Followers 0
Champak

Releasing files.

4 posts in this topic

#1 ·  Posted (edited)

If an app/script terminates abruptly does it release files or databases it has open? If it doesn't, how do I get them released?

I'm asking because I'm starting to work with databases, and I'm opening and closing them within functions, but thinking I should just open them when the app starts and close them when I close the app. Or is this direction not a good path?

Edited by Champak

Share this post


Link to post
Share on other sites

Why not use proper error handling to catch anything that would cause the script to abort, and handle your closing of the db or file there?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Because sometimes it may have nothing to do with an error with the app. S#!t simply happens sometimes with gremlins and an app exits. Due to the app, environment, OS, something. I can take care of general error handling, beyond those is why I'm asking.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

. S#!t simply happens sometimes

 

My first recommendation, is make a function that makes sure your environment is as you expect, and call that function on errors and before important actions. And use environmental variables and relative paths as much as possible.

The second thing I would suggest is to use AdlibRegister ( "function" [, time] ) to check your environment. But that can cause bugs, and requires the use of global variables.

 

If an app/script terminates abruptly does it release files or databases it has open?

It will be relased, and it depends on the type of database and app on how it handles corruption.

 

 

should just open them when the app starts and close them

It depends on performance and concurrency issues. But I that is the way I would suggest doing it. As far as odds of corrupting a database, I would think it makes no difference. Most databases are designed for always being open, with the expectation of possible undesired closing.

Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0