Skip to content
campadrenalin edited this page Sep 22, 2011 · 1 revision

ConcurrenTree.util.server.pool.pool

Pool

One of the most complex pieces of code in the codebase currently, the Pool is the magic manager that handles all the servers, their connections, and the bus that lets those connections talk to each other. Most of its functions are for its own internal use, so only a few are relevant to outside use.

Methods:
* __init__() # Creates the pool
* start(cls, *args, **kwargs) # Initializes a server of class cls with *args and **kwargs and runs it in a thread.
* run() # Run the pool (mostly calls process_server).
* run_threaded() # Creates a thread with self.run as the target, starts it, and returns the thread.
* process_server(i) # Interact with self.server(i) and its connections.
* connect(server, connection) # Register a connection from a server. Called by process_server.
* server(i) # return the i'th server in self.servers.
* thread(i) # return the thread of server(i).
* connections(i) # returns a list of all connections registered to server(i).
* buffer_flip() # Flips the bus buffer, discarding the old output side.
* properties() # returns a dict containing each server's properties.
* crash(e) # Contain an error and prevent it from taking down the whole program.
* close() # Close the pool from outside. DO NOT CALL FROM A SERVER.
* close_signal() # Function that lets servers request that the pool close.
* check_closed() # Raise an exception if pool is closed.

Properties:
* servers # a list of (server, thread, connections) tuples more easily accessed through functions.
* lock # A threading.Lock to maintain thread-safety in functions where it's a concern.
* notifyevent # A threading.Event used to wake the pool when Connections send new messages.
* env # A 2-element list of buffer halves (each of which is also a list).
* closed # Boolean

Serverpool System
Pylib Server

Clone this wiki locally