def aboutToQuit(): """now all connections to servers are cleanly closed""" mainWindow = Internal.mainWindow Internal.mainWindow = None if mainWindow: if Debug.quit: logDebug('aboutToQuit starting') if mainWindow.exitWaitTime > 1000.0 or Debug.quit: logDebug('reactor stopped after %d ms' % (mainWindow.exitWaitTime)) else: if Debug.quit: logDebug('aboutToQuit: mainWindow is already None') StateSaver.saveAll() Internal.app.quit() try: # if we are killed while loading, Internal.db may not yet be # defined if Internal.db: Internal.db.close() except NameError: pass checkMemory() logging.shutdown() if Debug.quit: logDebug('aboutToQuit ending')
def aboutToQuit(): """now all connections to servers are cleanly closed""" mainWindow = Internal.mainWindow Internal.mainWindow = None if mainWindow: if Debug.quit: logDebug(u'aboutToQuit starting') if mainWindow.exitWaitTime > 1000.0 or Debug.quit: logDebug( u'reactor stopped after %d ms' % (mainWindow.exitWaitTime)) else: if Debug.quit: logDebug(u'aboutToQuit: mainWindow is already None') StateSaver.saveAll() Internal.app.quit() try: # if we are killed while loading, Internal.db may not yet be # defined if Internal.db: Internal.db.close() except NameError: pass checkMemory() logging.shutdown() if Debug.quit: logDebug(u'aboutToQuit ending')
def appquit(): """retry until the reactor really stopped""" if Internal.reactor.running: Internal.quitWaitTime += 10 if Internal.quitWaitTime % 1000 == 0: logDebug('waiting since %d seconds for reactor to stop' % (Internal.quitWaitTime // 1000)) QTimer.singleShot(10, Client.appquit) else: if Internal.quitWaitTime > 1000: logDebug('reactor stopped after %d seconds' % (Internal.quitWaitTime // 1000)) Internal.app.quit() checkMemory()
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Copyright (C) 2009-2014 Wolfgang Rohdewald <*****@*****.**> Kajongg is free software you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. """ from server import kajonggServer from util import checkMemory kajonggServer() checkMemory() # profileMe()
if args and ''.join(args): print('unrecognized arguments:', ' '.join(args)) sys.exit(2) print() if OPTIONS.count: doJobs() if OPTIONS.csv: evaluate(readGames(OPTIONS.csv)) def cleanup(sig, dummyFrame): """at program end""" Server.stopAll() sys.exit(sig) # is one server for two clients. if __name__ == '__main__': signal.signal(signal.SIGABRT, cleanup) signal.signal(signal.SIGTERM, cleanup) signal.signal(signal.SIGINT, cleanup) if os.name != 'nt': signal.signal(signal.SIGHUP, cleanup) signal.signal(signal.SIGQUIT, cleanup) main() gc.collect() checkMemory()