Jump to content

Releasing files.


Champak
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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.

Link to comment
Share on other sites

. 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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...