Skip to main content

Questions tagged [atexit]

atexit(3) is a method for arranging a function to be called at a program's exit time.

0 votes
1 answer
34 views

Execute a last line of code when the user closes the console window

If we run a Python program in a console on Windows (python myscript.py), is there a possibility to run a last line of code when the user clicks on the "X" top-right button of the console ...
Basj's user avatar
  • 44.9k
0 votes
1 answer
260 views

Joining a thread started by a DLL prior to program termination on Windows

Background I am using the miniaudio library to implement the audio module in the open-source SFML 3.x library. As an attempt to simplify our audio resource management, I removed run-time reference ...
Vittorio Romeo's user avatar
0 votes
1 answer
54 views

Python shutil.copytree: [WinError 32] The process cannot access the file because it is being used by another process

On GitHub I share an PyInstaller generated exe-File (file1.exe). The idea is an automatized update process if there is a new version of the file. On every start of file1.exe the program checks if ...
Fab's user avatar
  • 11
0 votes
0 answers
45 views

Is there a way to make sure your std::atexit function works when stopping the Xcode debugger?

Found that when you halt your C++ program from Xcode using "Stop Debugging", your atexit function gets skipped Any way to do this, especially when debugging an iOS app?
bobobobo's user avatar
  • 66.6k
0 votes
1 answer
49 views

Unable to delete table from AstraDb when closing Flask app using atexit()

app = Flask(__name__) # AstraDB connection and vector store initialization def initialize_astra_vector_store(): cassio.init(token=ASTRA_DB_APPLICATION_TOKEN, database_id=ASTR_DB_ID) ...
Hamza Khan's user avatar
0 votes
1 answer
69 views

atexit registered function unable to access streamlit session state variable

I have registered an atexit function like this: import streamlit as st from azure.search.documents.indexes import SearchIndexClient from azure.core.credentials import AzureKeyCredential @atexit....
AnonymousMe's user avatar
0 votes
0 answers
25 views

pyinstaller exe with console window does not execute finally block or atexit when closing

I am trying to run code when my script is closed. def main(): atexit.register(disconnect) try: do_something() while True: os.system('cls') print("...
dice's user avatar
  • 11
-1 votes
1 answer
52 views

How can I fix a RuntimeWarning using the 'atexit' module?

Recently, I've been wanting to create an exit handler for my discord bot which sends an embed every time it goes offline. I found out through some quick research about the atexit module. I tried to ...
Planetech's user avatar
0 votes
1 answer
69 views

WinAPI - how to run some clean up code on forceful exit

I have this snippet: #include <windows.h> class Conf { public: Conf(int i) : m_i{ i } { MessageBoxA(NULL, "Conf", "", MB_OK); } ~...
coderodde's user avatar
  • 927
1 vote
0 answers
107 views

atexit module not working when stopped with vsCode

I am coding a discord bot in discord.py. I want it to change the role of the bot to show it's offline when the code is stopped. Here's the relevant code: import atexit, signal class MyClient(discord....
Mildly Intelligent's user avatar
0 votes
1 answer
42 views

Why does callback not called which is defined with @atexit.register at sys.exit in Python? [duplicate]

Description: I wonder that why does callback not called which is defined with @atexit.register at sys.exit in Python? Code 1: import atexit import sys if __name__ == '__main__': @atexit.register ...
黃奕捷's user avatar
1 vote
3 answers
139 views

atexit(3) in Perl: `END {}` or `$SIG{__DIE__}`?

I'm wondering: When you detect you need to clean up at the end of the program (excluding "end of block"), you want to "queue an exit handler" that does the cleanup at some later ...
U. Windl's user avatar
  • 4,069
4 votes
0 answers
32 views

Register a callback to handle JLI_Launch failing with "Could not find or load main class"

I am trying to make AppBundler more observable and have had great success except for one thing. JLI_Launch does not return to the caller so I can't tell if it fails to load the main class (or any ...
Jeff Holt's user avatar
  • 3,200
0 votes
1 answer
78 views

How to close a process using "atexit" and "subprocess" module when the user close the script

So in my script I run an executable file in headless. But I need to close it when the user exit/close the script. I tried this code but it doesn't work, run.exe is still running in background. (I ...
Smoodie's user avatar
  • 15
0 votes
1 answer
239 views

upload a file to s3 after script end/crashes: cannot schedule new futures after interpreter shutdown

I need to upload a file to s3 no matter how a script end/interrupts. I have done: import atexit import signal atexit.register(exit_handler) signal.signal(signal.SIGINT, exit_handler) signal.signal(...
00__00__00's user avatar
  • 5,147

15 30 50 per page
1
2 3 4 5
12