kxg.quickstart.ProcessPool

class kxg.quickstart.ProcessPool(time_limit=None, frame_rate=30)[source]

Bases: object

Manage a group of processes running instances of the game loop.

This class wraps around the basic multiprocessing functionality available in the python standard library. There are two nice features provided by this class. The first is that log messages generated in the subprocesses are automatically relayed to the main process, where they are reported with the name of the original process included and without any mangling due to race conditions. The second is that exceptions, which are usually silently ignored in subprocesses, are also relayed to the main process and re-raised.

This class is actually not specific to the game engine at all, so in principle it could be moved into it’s own library. I decided not to do that because I can’t think of any other scenario where I would want the functionality that this class offers, but maybe I’ll think of one later.

Public Methods:

__init__([time_limit, frame_rate])

Initialize self.

__enter__()

__exit__(*args)

start(name, worker, *args, **kwargs)

Private Methods:

_run_worker(name, worker, *args, **kwargs)

_run_supervisor()

Poll the queues that the worker can use to communicate with the supervisor, until all the workers are done and all the queues are empty.

__enter__()[source]
__exit__(*args)[source]
__init__(time_limit=None, frame_rate=30)[source]

Initialize self. See help(type(self)) for accurate signature.

_run_supervisor()[source]

Poll the queues that the worker can use to communicate with the supervisor, until all the workers are done and all the queues are empty. Handle messages as they appear.

_run_worker(name, worker, *args, **kwargs)[source]
start(name, worker, *args, **kwargs)[source]