Package brisa :: Package core :: Package reactors :: Module _select :: Class SelectReactor
[hide private]
[frames] | no frames]

Class SelectReactor

source code

           object --+        
                    |        
  singleton.Singleton --+    
                        |    
ireactor.ReactorInterface --+
                            |
                           SelectReactor

Nested Classes [hide private]

Inherited from singleton.Singleton: __metaclass__

Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
integer
add_timer(self, interval, callback, threshold=0.01)
Adds a timer.
source code
 
rem_timer(self, id)
Removes a timed callback given its id.
source code
 
add_fd(self, fd, evt_callback, evt_type, data=None)
Adds a fd for watch.
source code
 
rem_fd(self, fd)
Removes a fd from being watched.
source code
 
add_after_stop_func(self, func)
Registers a function to be called before entering the STOPPED state.
source code
 
rem_after_stop_func(self, func)
Removes a registered function.
source code
 
add_before_start_func(self, func)
Registers a function to be called before entering the RUNNING state.
source code
 
rem_before_start_func(self, func)
Removes a registered function.
source code
 
main(self)
Enters the RUNNING state by running the main loop until main_quit() is called.
source code
 
main_quit(self)
Terminates the main loop.
source code
 
main_loop_iterate(self)
Runs a single iteration of the main loop.
source code
 
is_running(self)
Returns True if the main loop is running.
source code
boolean
_main_select(self)
Selects and process events.
source code
 
_main_process_events(self, revt, wevt, eevt) source code
 
_main_trigger_timers(self)
Triggers the timers that are ready.
source code
 
_main_cleanup_fds(self)
Cleans up problematic fds.
source code
 
_get_min_timeout(self)
Returns the minimum timeout among registered timers.
source code
 
_main_call_before_stop_funcs(self) source code
 
_main_call_before_start_funcs(self) source code
 
_main_sig_quit(self, sig, frame) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  _timers = {}
  _read_fds = {}
  _write_fds = {}
  _excpt_fds = {}
  _stop_funcs = []
  _start_funcs = []
  state = REACTOR_STATE_STOPPED
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

add_timer(self, interval, callback, threshold=0.01)

source code 

Adds a timer.

Parameters:
  • interval (integer) - interval to sleep between calls
  • callback (callable) - function to be called
  • threshold (float) - lower bound for the time precision
Returns: integer
unique ID for the callback
Overrides: ireactor.ReactorInterface.add_timer

rem_timer(self, id)

source code 

Removes a timed callback given its id.

Parameters:
  • id (integer) - unique ID returned by add_timer()
Overrides: ireactor.ReactorInterface.rem_timer

add_fd(self, fd, evt_callback, evt_type, data=None)

source code 

Adds a fd for watch.

Parameters:
  • fd (file) - file descriptor
  • evt_callback (callable) - callback to be called
  • evt_type (integer) - event type to be watched on this fd. An OR combination of EVENT_TYPE_* flags.
  • data (any) - data to be forwarded to the callback
Overrides: ireactor.ReactorInterface.add_fd

rem_fd(self, fd)

source code 

Removes a fd from being watched.

Parameters:
  • fd (file) - file descriptor to be removed
Overrides: ireactor.ReactorInterface.rem_fd

add_after_stop_func(self, func)

source code 

Registers a function to be called before entering the STOPPED state.

Parameters:
  • func (callable) - function
Overrides: ireactor.ReactorInterface.add_after_stop_func

rem_after_stop_func(self, func)

source code 

Removes a registered function.

Parameters:
  • func (callable) - function
Overrides: ireactor.ReactorInterface.rem_after_stop_func

add_before_start_func(self, func)

source code 

Registers a function to be called before entering the RUNNING state.

Parameters:
  • func (callable) - function
Overrides: ireactor.ReactorInterface.add_before_start_func

rem_before_start_func(self, func)

source code 

Removes a registered function.

Parameters:
  • func (callable) - function
Overrides: ireactor.ReactorInterface.rem_before_start_func

main(self)

source code 

Enters the RUNNING state by running the main loop until main_quit() is called.

Overrides: ireactor.ReactorInterface.main

main_quit(self)

source code 

Terminates the main loop.

Overrides: ireactor.ReactorInterface.main_quit

main_loop_iterate(self)

source code 

Runs a single iteration of the main loop. Reactor enters the RUNNING state while this method executes.

Overrides: ireactor.ReactorInterface.main_loop_iterate

is_running(self)

source code 

Returns True if the main loop is running. Otherwise returns False.

Overrides: ireactor.ReactorInterface.is_running
(inherited documentation)

_main_select(self)

source code 

Selects and process events.

Returns: boolean
True if no exception was raised. False if an exception was raised, meaning that we recommend another _main_select()