OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Executing a function when the console window closes?

  • Thread starter Thread starter Hunger
  • Start date Start date
H

Hunger

Guest
I want to execute a function when the program is closed by user.

For example, if the main program is time.sleep(1000),how can I write a txt to record unexpected termination of the program.

The program is packaged into exe by cxfreeze. Click the "X" to close the console window.

I know atexit can deal with sys.exit(),but is there a more powerful way can deal with close window event?

Questions

  1. Is this possible in Python?
  2. If so, how can I do this?
<p>I want to execute a function when the program is closed by user.</p>

<p>For example, if the main program is <code>time.sleep(1000)</code>,how can I write a txt to record unexpected termination of the program.</p>

<p>The program is packaged into exe by cxfreeze. Click the "X" to close the console window.</p>

<p>I know <a href="http://docs.python.org/3.3/library/atexit.html" rel="nofollow">atexit</a> can deal with sys.exit(),but is there a more powerful way can deal with close window event?</p>

<p><strong>Questions</strong></p>

<ol>
<li>Is this possible in Python?</li>
<li>If so, how can I do this?</li>
</ol>
 

Online statistics

Members online
0
Guests online
4
Total visitors
4
Top