¡@

Home 

python Programming Glossary: atexit.register

Embedding IPython Qt console in a PyQt application

http://stackoverflow.com/questions/11513132/embedding-ipython-qt-console-in-a-pyqt-application

hb self._heartbeat self.kernel_manager km atexit.register self.kernel_manager.cleanup_connection_file def connect_kernel.. manager.load_connection_file manager.start_channels atexit.register manager.cleanup_connection_file return manager def console_widget..

Give the Python Terminal a Persistent History

http://stackoverflow.com/questions/12334316/give-the-python-terminal-a-persistent-history

historyPath readline.read_history_file historyPath atexit.register save_history del os atexit readline rlcompleter save_history..

Killing child process when parent crashes in python

http://stackoverflow.com/questions/14128410/killing-child-process-when-parent-crashes-in-python

process subprocess share improve this question I would atexit.register a function to terminate the process import atexit process subprocess.Popen.. atexit process subprocess.Popen args.server_file_path atexit.register process.terminate pid process.pid Or maybe import atexit process.. atexit process subprocess.Popen args.server_file_path @atexit.register def kill_process try process.terminate except OSError pass #ignore..

How to create a menu and submenus in Python curses?

http://stackoverflow.com/questions/14200721/how-to-create-a-menu-and-submenus-in-python-curses

0 self.datum k v self.ordered.append k self.title title atexit.register self.cleanup def cleanup self curses.doupdate curses.endwin..

Prevent a console app from closing when not invoked from an existing terminal?

http://stackoverflow.com/questions/2258771/prevent-a-console-app-from-closing-when-not-invoked-from-an-existing-terminal

terminal def press_any_key if os.name nt os.system pause atexit.register press_any_key It's also making the assumption that all Windows.. if not GetConsoleTitle .startswith os.environ COMSPEC atexit.register lambda os.system pause if __name__ '__main__' register_pause_before_closing_console.. os pdb if os.name 'nt' if _current_process_owns_console atexit.register lambda os.system pause if __name__ '__main__' register_pause_before_closing_console..

Detect user logout / shutdown in Python / GTK under Linux - SIGTERM/HUP not received

http://stackoverflow.com/questions/2490166/detect-user-logout-shutdown-in-python-gtk-under-linux-sigterm-hup-not-rece

args clean sig def at open at_event wb import atexit atexit.register at f Test sys.exitfunc ex gtk.quit_add gtk.main_level foo gtk.main..

Ensuring subprocesses are dead on exiting Python program

http://stackoverflow.com/questions/320232/ensuring-subprocesses-are-dead-on-exiting-python-program

any clean up tasks to be run when your program exits. atexit.register func args kargs In your cleanup process you can also implement.. # supported from python 2.6 ... print 'cleaned up ' ... atexit.register cleanup sys.exit cleaned up Note Registered functions won't..

Linux: Pipe into Python (ncurses) script, stdin and termios

http://stackoverflow.com/questions/3999114/linux-pipe-into-python-ncurses-script-stdin-and-termios

print curses writetxt try myscreen curses.initscr #~ atexit.register curses.endwin except print Unexpected error sys.exc_info 0 sys.stderr.write.. writetxt myscreen.refresh myscreen.getch #~ curses.endwin atexit.register curses.endwin sys.stderr.write after end # this won't show even..

How to repeat last command in python interpreter shell?

http://stackoverflow.com/questions/4289937/how-to-repeat-last-command-in-python-interpreter-shell

readline.read_history_file histfile except IOError pass atexit.register readline.write_history_file histfile del os histfile readline..

Multi threaded web scraper using urlretrieve on a cookie-enabled site

http://stackoverflow.com/questions/6111372/multi-threaded-web-scraper-using-urlretrieve-on-a-cookie-enabled-site

SiteBase _SiteBase global DataPath DataPath _DataPath atexit.register Logout def DownloadJob link mechanize.urlretrieve mechanize.urljoin.. DataPath ' ' current_process .name 'cookies.txt' True True atexit.register Logout def DownloadJob link cj mechanize.LWPCookieJar cj.revert..

Cleaning up an internal pysqlite connection on object destruction

http://stackoverflow.com/questions/974813/cleaning-up-an-internal-pysqlite-connection-on-object-destruction

global con if not con con sqlite3.connect 'somedb.sqlite' atexit.register close_connection con return con def close_connection some_con..