Package pyxmpp2 :: Package mainloop :: Module threads :: Class ThreadPool
[hide private]

Class ThreadPool


Thread pool object, as a replacement for an asychronous event loop.
Nested Classes [hide private]

Inherited from interfaces.MainLoop: __metaclass__

Instance Methods [hide private]
 
__init__(self, settings=None, handlers=None)
x.__init__(...) initializes x; see help(type(x)) for signature
 
add_handler(self, handler)
Add a new handler to the main loop.
 
remove_handler(self, handler)
Add a new handler to the main loop.
 
_add_io_handler(self, handler)
Add an IOHandler to the pool.
 
_run_io_threads(self, handler)
Start threads for an IOHandler.
 
_remove_io_handler(self, handler)
Remove an IOHandler from the pool.
 
_add_timeout_handler(self, handler)
Add a TimeoutHandler to the pool.
 
_run_timeout_threads(self, handler)
Start threads for a TimeoutHandler.
 
_remove_timeout_handler(self, handler)
Remove a TimeoutHandler from the pool.
 
start(self, daemon=False)
Start the threads.
 
stop(self, join=False, timeout=None)
Stop the threads.
 
quit(self)
Make the loop stop after the current iteration.
 
loop(self, timeout=None)
Run the loop.
 
loop_iteration(self, timeout=0.1)
Wait up to timeout seconds, raise any exception from the threads.

Inherited from interfaces.MainLoop: delayed_call

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

Class Variables [hide private]
  __abstractmethods__ = frozenset([])
Properties [hide private]
  finished
True then the loop has been finished or is about to finish (the final iteration in progress).
  started
True then the loop has been started.

Inherited from object: __class__

Method Details [hide private]

__init__(self, settings=None, handlers=None)
(Constructor)

 
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__
(inherited documentation)

add_handler(self, handler)

 
Add a new handler to the main loop.
Parameters:
  • handler - the handler object to add
Overrides: interfaces.MainLoop.add_handler
(inherited documentation)

remove_handler(self, handler)

 

Add a new handler to the main loop.

Do nothing if the handler is not registered at the main loop.

Parameters:
  • handler - the handler object to add
Overrides: interfaces.MainLoop.remove_handler
(inherited documentation)

stop(self, join=False, timeout=None)

 
Stop the threads.
Parameters:
  • join - join the threads (wait until they exit)
  • timeout - maximum time (in seconds) to wait when join is True). No limit when timeout is None.

quit(self)

 
Make the loop stop after the current iteration.
Overrides: interfaces.MainLoop.quit
(inherited documentation)

loop(self, timeout=None)

 
Run the loop.
Parameters:
  • timeout - time to loop, if not given the method will run until finished
Overrides: interfaces.MainLoop.loop
(inherited documentation)

loop_iteration(self, timeout=0.1)

 
Wait up to timeout seconds, raise any exception from the threads.
Parameters:
  • timeout - maximum time (in seconds) to block for
Overrides: interfaces.MainLoop.loop_iteration

Property Details [hide private]

finished

True then the loop has been finished or is about to finish (the final iteration in progress).
Get Method:
unreachable.finished(self)

started

True then the loop has been started.
Get Method:
unreachable.started(self)