def makeSession(self): """Generate a new Session instance, and store it for future reference. """ uid = self._mkuid() s = Session(self, uid) session = self.sessions[uid] = s main.addTimeout(s.expire, 1800) return session
def expire(self): # If I haven't been touched in 15 minutes: if time.time() - self.lastModified > 900: if self.site.sessions.has_key(self.uid): log.msg("expired session %s" % self.uid) del self.site.sessions[self.uid] else: log.msg("no session to expire: %s" % self.uid) else: log.msg("session given the will to live for 30 more minutes") main.addTimeout(self.expire, 1800)
def __init__(self): opts = testopt.parseCommandLine(800, 600) pyui.init(800,600,"p3d") ## DB init stuff self.dbpool = adbapi.ConnectionPool("pyPgSQL.PgSQL", "sean", host="localhost:5432") self.application = app.Application("testApp") self.reflector = sqlreflector.SQLReflector(self.dbpool, [], self.makeGrids) main.addTimeout(self.tick, 0.001) # make sure we can be shut down on windows. self.application.run()
def tick(self): try: pyui.core.update() pyui.core.draw() except: #TODO: handle exceptions properly! print "Exception in pyui" raise main.addTimeout(self.tick, 0.001) if not getDesktop().running: main.shutDown() pyui.quit() now = time.time() if now - self.last > 1: print "FPS:", self.frames self.frames = 0 self.last = now self.frames = self.frames + 1
def tick(): main.addTimeout(tick, 0.5)
def tick(): main.addTimeout(tick, 0.5) if __name__ == '__main__': # init pyui pyui.init(800,600, "p3d") # init db stuff dbpool = adbapi.ConnectionPool("pyPgSQL.PgSQL", database="sean", host="localhost", port=5432) reflector = sqlreflector.SQLReflector(dbpool, [IdentityRow, PerspectiveRow]) reflector._transPopulateSchema(None) # make sure we can be shut down on windows. main.addTimeout(tick, 0.5) # create the boat frame w = pyui.boat.BoatReflectorFrame(reflector, 0,0,790, 570) # run the main loop last = 0 frame = 0 try: while pyui.update(): pyui.draw() main.iterate() frame += 1 now = time.time() if now - last > 2: print "FPS: ", int(frame/2)