def __init__(self, config=None, noisy=True): """config is a dict that contains option-value pairs. """ RawServerMixin.__init__(self, config, noisy) self.doneflag = None # init is fine until the loop starts self.ident = thread.get_ident() self.associated = False self.single_sockets = set() self.unix_sockets = set() self.udp_sockets = set() self.listened = False self.connections = 0 ############################################################## if profile: try: os.unlink(prof_file_name) except: pass self.prof = Profiler() ############################################################## self.connection_limit = self.config.get('max_incomplete', 10) connectionRateLimitReactor(reactor, self.connection_limit) # bleh self.add_pending_connection = reactor.add_pending_connection self.remove_pending_connection = reactor.remove_pending_connection self.reactor = reactor self.reactor.resolver = SaneThreadedResolver(self.reactor)
def OnInit(self): self.running = True if profile: try: os.unlink(prof_file_name) except: pass self.prof = Profiler() self.prof.enable() wx.the_app = self self._DoIterationId = wx.NewEventType() self.Connect(-1, -1, self._DoIterationId, self._doIteration) self.evt = wx.PyEvent() self.evt.SetEventType(self._DoIterationId) self.event_queue = [] # this breaks TreeListCtrl, and I'm too lazy to figure out why #wx.IdleEvent_SetMode(wx.IDLE_PROCESS_SPECIFIED) # this fixes 24bit-color toolbar buttons wx.SystemOptions_SetOptionInt("msw.remap", 0) icon_path = os.path.join(image_root, 'bittorrent.ico') self.icon = wx.Icon(icon_path, wx.BITMAP_TYPE_ICO) return True
t = task.LoopingCall(push) t.start(freq) ## m = MultiRateLimiter(sched=rawserver.add_task) ## m.set_parameters(120000000) ## class C(object): ## def send_partial(self, size): ## global_rate.print_rate(size) ## rawserver.add_task(0, m.queue, self) ## return size ## ## m.queue(C()) if profile: try: os.unlink(prof_file_name) except: pass prof = Profiler() prof.enable() rawserver.listen_forever() if profile: prof.disable() st = Stats(prof.getstats()) st.sort() f = open(prof_file_name, 'wb') st.dump(file=f)