Python gobject.source_remove() Examples

The following are 30 code examples of gobject.source_remove(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gobject , or try the search function .
Example #1
Source File: bluezchat.py    From python-for-android with Apache License 2.0 6 votes vote down vote up
def data_ready(self, sock, condition):
        address = self.addresses[sock]
        data = sock.recv(1024)

        if len(data) == 0:
            self.add_text("\nlost connection with %s" % address)
            gobject.source_remove(self.sources[address])
            del self.sources[address]
            del self.peers[address]
            del self.addresses[sock]
            sock.close()
        else:
            self.add_text("\n%s - %s" % (address, str(data)))
        return True

# --- other stuff 
Example #2
Source File: gtk2reactor.py    From python-for-android with Apache License 2.0 6 votes vote down vote up
def doIteration(self, delay):
        # flush some pending events, return if there was something to do
        # don't use the usual "while self.context.pending(): self.context.iteration()"
        # idiom because lots of IO (in particular test_tcp's
        # ProperlyCloseFilesTestCase) can keep us from ever exiting.
        log.msg(channel='system', event='iteration', reactor=self)
        if self.__pending():
            self.__iteration(0)
            return
        # nothing to do, must delay
        if delay == 0:
            return # shouldn't delay, so just return
        self.doIterationTimer = gobject.timeout_add(int(delay * 1000),
                                                self.doIterationTimeout)
        # This will either wake up from IO or from a timeout.
        self.__iteration(1) # block
        # note: with the .simulate timer below, delays > 0.1 will always be
        # woken up by the .simulate timer
        if self.doIterationTimer:
            # if woken by IO, need to cancel the timer
            gobject.source_remove(self.doIterationTimer)
            self.doIterationTimer = None 
Example #3
Source File: gtk2reactor.py    From BitTorrent with GNU General Public License v3.0 6 votes vote down vote up
def doIteration(self, delay):
        # flush some pending events, return if there was something to do
        # don't use the usual "while self.context.pending(): self.context.iteration()"
        # idiom because lots of IO (in particular test_tcp's
        # ProperlyCloseFilesTestCase) can keep us from ever exiting.
        log.msg(channel='system', event='iteration', reactor=self)
        if self.__pending():
            self.__iteration(0)
            return
        # nothing to do, must delay
        if delay == 0:
            return # shouldn't delay, so just return
        self.doIterationTimer = gobject.timeout_add(int(delay * 1000),
                                                self.doIterationTimeout)
        # This will either wake up from IO or from a timeout.
        self.__iteration(1) # block
        # note: with the .simulate timer below, delays > 0.1 will always be
        # woken up by the .simulate timer
        if self.doIterationTimer:
            # if woken by IO, need to cancel the timer
            gobject.source_remove(self.doIterationTimer)
            self.doIterationTimer = None 
Example #4
Source File: gtk2reactor.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def removeReader(self, reader):
        if hasReader(reader):
            gobject.source_remove(reads[reader])
            del reads[reader] 
Example #5
Source File: core.py    From ns3-ecn-sharp with GNU General Public License v2.0 5 votes vote down vote up
def _on_play_button_toggled(self, button):
        if button.get_active():
            self._start_update_timer()
        else:
            if self._update_timeout_id is not None:
                gobject.source_remove(self._update_timeout_id) 
Example #6
Source File: core.py    From ns3-ecn-sharp with GNU General Public License v2.0 5 votes vote down vote up
def _start_update_timer(self):
        if self._update_timeout_id is not None:
            gobject.source_remove(self._update_timeout_id)
        #print "start_update_timer"
        self._update_timeout_id = gobject.timeout_add(int(SAMPLE_PERIOD/min(self.speed, 1)*1e3),
                                                      self.update_view_timeout,
                                                      priority=PRIORITY_UPDATE_VIEW) 
Example #7
Source File: xdot.py    From POC-EXP with GNU General Public License v3.0 5 votes vote down vote up
def stop(self):
        self.dot_widget.animation = NoAnimation(self.dot_widget)
        if self.timeout_id is not None:
            gobject.source_remove(self.timeout_id)
            self.timeout_id = None 
Example #8
Source File: core.py    From Tocino with GNU General Public License v2.0 5 votes vote down vote up
def _start_update_timer(self):
        if self._update_timeout_id is not None:
            gobject.source_remove(self._update_timeout_id)
        #print "start_update_timer"
        self._update_timeout_id = gobject.timeout_add(int(SAMPLE_PERIOD/min(self.speed, 1)*1e3),
                                                      self.update_view_timeout,
                                                      priority=PRIORITY_UPDATE_VIEW) 
Example #9
Source File: core.py    From Tocino with GNU General Public License v2.0 5 votes vote down vote up
def _on_play_button_toggled(self, button):
        if button.get_active():
            self._start_update_timer()
        else:
            if self._update_timeout_id is not None:
                gobject.source_remove(self._update_timeout_id) 
Example #10
Source File: core.py    From Tocino with GNU General Public License v2.0 5 votes vote down vote up
def _quit(self, *dummy_args):
        if self._update_timeout_id is not None:
            gobject.source_remove(self._update_timeout_id)
            self._update_timeout_id = None
        self.simulation.quit = True
        self.simulation.go.set()
        self.simulation.join()
        gtk.main_quit() 
Example #11
Source File: invocation.py    From gimp-plugin-export-layers with GNU General Public License v3.0 5 votes vote down vote up
def timeout_remove_strict(callback):
  """
  Remove a callback scheduled by `timeout_add_strict()`. If no such callback
  exists, do nothing.
  """
  if callback in _timer_ids:
    gobject.source_remove(_timer_ids[callback])
    del _timer_ids[callback] 
Example #12
Source File: xdot.py    From EasY_HaCk with Apache License 2.0 5 votes vote down vote up
def stop(self):
        self.dot_widget.animation = NoAnimation(self.dot_widget)
        if self.timeout_id is not None:
            gobject.source_remove(self.timeout_id)
            self.timeout_id = None 
Example #13
Source File: util.py    From tapas with GNU General Public License v2.0 5 votes vote down vote up
def stop(self):
        self.running = False
        if self.calc_iteration_id:
            gobject.source_remove(self.calc_iteration_id)
            self.calc_iteration_id = None 
Example #14
Source File: backend_gtk.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def _timer_stop(self):
        if self._timer is not None:
            gobject.source_remove(self._timer)
            self._timer = None 
Example #15
Source File: backend_gtk.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def destroy(self):
        #gtk.DrawingArea.destroy(self)
        self.close_event()
        if self._idle_draw_id != 0:
            gobject.source_remove(self._idle_draw_id) 
Example #16
Source File: core.py    From ns3-802.11ad with GNU General Public License v2.0 5 votes vote down vote up
def _quit(self, *dummy_args):
        if self._update_timeout_id is not None:
            gobject.source_remove(self._update_timeout_id)
            self._update_timeout_id = None
        self.simulation.quit = True
        self.simulation.go.set()
        self.simulation.join()
        gtk.main_quit() 
Example #17
Source File: gtk2reactor.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def removeWriter(self, writer):
        if hasWriter(writer):
            gobject.source_remove(writes[writer])
            del writes[writer] 
Example #18
Source File: gtk2reactor.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def simulate(self):
        """Run simulation loops and reschedule callbacks.
        """
        global _simtag
        if _simtag is not None:
            gobject.source_remove(_simtag)
        self.runUntilCurrent()
        timeout = min(self.timeout(), 0.1)
        if timeout is None:
            timeout = 0.1
        # grumble
        _simtag = gobject.timeout_add(int(timeout * 1010), self.simulate) 
Example #19
Source File: gtk2reactor.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def simulate(self):
        """
        Run simulation loops and reschedule callbacks.
        """
        if self._simtag is not None:
            gobject.source_remove(self._simtag)
        self.runUntilCurrent()
        timeout = min(self.timeout(), 0.1)
        if timeout is None:
            timeout = 0.1
        # grumble
        self._simtag = gobject.timeout_add(int(timeout * 1010), self.simulate) 
Example #20
Source File: gtk2reactor.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def _remove(self, source, primary, other, flags):
        """
        Remove monitoring the given L{FileDescriptor} for either reading or
        writing. If it's still monitored for the other operation, we
        re-register the L{FileDescriptor} for only that operation.
        """
        if source not in primary:
            return
        gobject.source_remove(self._sources[source])
        primary.remove(source)
        if source in other:
            self._sources[source] = self.input_add(
                source, flags, self.callback)
        else:
            self._sources.pop(source) 
Example #21
Source File: gtk2reactor.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def _add(self, source, primary, other, primaryFlag, otherFlag):
        """
        Add the given L{FileDescriptor} for monitoring either for reading or
        writing. If the file is already monitored for the other operation, we
        delete the previous registration and re-register it for both reading
        and writing.
        """
        if source in primary:
            return
        flags = primaryFlag
        if source in other:
            gobject.source_remove(self._sources[source])
            flags |= otherFlag
        self._sources[source] = self.input_add(source, flags, self.callback)
        primary.add(source) 
Example #22
Source File: core.py    From CRE-NS3 with GNU General Public License v2.0 5 votes vote down vote up
def _quit(self, *dummy_args):
        if self._update_timeout_id is not None:
            gobject.source_remove(self._update_timeout_id)
            self._update_timeout_id = None
        self.simulation.quit = True
        self.simulation.go.set()
        self.simulation.join()
        gtk.main_quit() 
Example #23
Source File: core.py    From CRE-NS3 with GNU General Public License v2.0 5 votes vote down vote up
def _on_play_button_toggled(self, button):
        if button.get_active():
            self._start_update_timer()
        else:
            if self._update_timeout_id is not None:
                gobject.source_remove(self._update_timeout_id) 
Example #24
Source File: core.py    From CRE-NS3 with GNU General Public License v2.0 5 votes vote down vote up
def _start_update_timer(self):
        if self._update_timeout_id is not None:
            gobject.source_remove(self._update_timeout_id)
        #print "start_update_timer"
        self._update_timeout_id = gobject.timeout_add(int(SAMPLE_PERIOD/min(self.speed, 1)*1e3),
                                                      self.update_view_timeout,
                                                      priority=PRIORITY_UPDATE_VIEW) 
Example #25
Source File: xdot.py    From openxenmanager with GNU General Public License v2.0 5 votes vote down vote up
def stop(self):
        self.dot_widget.animation = NoAnimation(self.dot_widget)
        if self.timeout_id is not None:
            gobject.source_remove(self.timeout_id)
            self.timeout_id = None 
Example #26
Source File: backend_gtk.py    From ImageFusion with MIT License 5 votes vote down vote up
def destroy(self):
        #gtk.DrawingArea.destroy(self)
        self.close_event()
        gobject.source_remove(self._idle_event_id)
        if self._idle_draw_id != 0:
            gobject.source_remove(self._idle_draw_id) 
Example #27
Source File: backend_gtk.py    From ImageFusion with MIT License 5 votes vote down vote up
def _timer_stop(self):
        if self._timer is not None:
            gobject.source_remove(self._timer)
            self._timer = None 
Example #28
Source File: __init__.py    From launcher with GNU General Public License v3.0 5 votes vote down vote up
def KeyDown(self,event):
        if IsKeyMenuOrB(event.key):
            gobject.source_remove(self._DownloaderTimer)
            self._DownloaderTimer = -1
            
            #if self._Downloader != None:
            #    try:
            #        self._Downloader.stop()
            #    except:
            #        print("user canceled ")
            
            self.ReturnToUpLevelPage()
            self._Screen.Draw()
            self._Screen.SwapAndShow() 
Example #29
Source File: __init__.py    From launcher with GNU General Public License v3.0 5 votes vote down vote up
def KeyDown(self,event):
        if IsKeyMenuOrB(event.key):
            gobject.source_remove(self._DownloaderTimer)
            self._DownloaderTimer = -1
            
            if self._Downloader != None:
                try:
                    self._Downloader.stop()
                except:
                    print("user canceled ")
            
            self.ReturnToUpLevelPage()
            self._Screen.Draw()
            self._Screen.SwapAndShow()
            self._URL = None 
Example #30
Source File: __init__.py    From launcher with GNU General Public License v3.0 5 votes vote down vote up
def Leave(self):
        if self._DownloaderTimer != -1:
            gobject.source_remove(self._DownloaderTimer)
        self._DownloaderTimer = -1
            
        if self._Downloader != None:
            try:
                self._Downloader.stop()
            except:
                print("user canceled ")
            
        self.ReturnToUpLevelPage()
        self._Screen.Draw()
        self._Screen.SwapAndShow()
        self._URL = None