def on_close(e): twitter.disconnect() import AsyncoreThread AsyncoreThread.join() f.Destroy()
def main(): fix_logging() AsyncoreThread.start() import wx; a = testapp('../../..') a.toggle_crust() from jabber import protocol global jabber jargs, jkwargs = connection_settings['gtalk'] jabber = protocol(*jargs, **jkwargs) jabber.Connect() a.MainLoop() try: jabber.Disconnect() except: pass AsyncoreThread.join(timeout = None)
def main(): fix_logging() AsyncoreThread.start() import wx a = testapp('../../..') a.toggle_crust() from jabber import protocol global jabber jargs, jkwargs = connection_settings['gtalk'] jabber = protocol(*jargs, **jkwargs) jabber.Connect() a.MainLoop() try: jabber.Disconnect() except: pass AsyncoreThread.join(timeout=None)
AT.start() srv = HTTPServerManager() class ClosingHandler(DefaultHandler): def handle(self, client, request): print "closing!" client.push("HTTP/1.1 200 OK\r\n" "Connection: close\r\n" "\r\n" "server has been shutdown") client.close() srv.shutdown() host, port = srv.serve("/close", ClosingHandler, host="", port=0) srv.serve(lambda *a: True, DefaultHandler, host="", port=0) print AT.net_thread.map import time time.sleep(1) import urllib2 try: for url in ("http://localhost:{port}/foo/bar", "http://localhost:{port}/close", "http://localhost:{port}/blah"): x = urllib2.urlopen(url.format(**locals())) print x.read() x.close() except Exception, e: print "urlopenerror:", e time.sleep(1) AT.join()
class ClosingHandler(DefaultHandler): def handle(self, client, request): print 'closing!' client.push('HTTP/1.1 200 OK\r\n' 'Connection: close\r\n' '\r\n' 'server has been shutdown') client.close() srv.shutdown() host, port = srv.serve('/close', ClosingHandler, host='', port=0) srv.serve(lambda *a: True, DefaultHandler, host='', port=0) print AT.net_thread.map import time time.sleep(1) import urllib2 try: for url in ( 'http://localhost:{port}/foo/bar', 'http://localhost:{port}/close', 'http://localhost:{port}/blah', ): x = urllib2.urlopen(url.format(**locals())) print x.read() x.close() except Exception, e: print 'urlopenerror:', e time.sleep(1) AT.join()