5.7.1. vlcp.utils.connector

Note

This document is generated from the source file.

View Source on GitHub

Created on 2015/11/30

author:hubo

Process events multi-threaded or multi-processed

class vlcp.utils.connector.Connector(worker_start, matchers=(), scheduler=None, mp=True, inputlimit=0, allowcontrol=True)
__init__(worker_start, matchers=(), scheduler=None, mp=True, inputlimit=0, allowcontrol=True)
Parameters:
  • worker_start – func(queuein, queueout), queuein is the input queue, queueout is the output queue. For queuein, each object is (event, matcher) tuple; For queueout, each object is a tuple of events to send. Every object in queuein must have a response in queueout.
  • matcheres – match events to be processed by connector.
  • scheduler – bind to specified scheduler
  • mp – use multiprocessing if possible. For windows, multi-threading is always used.
  • inputlimit – input queue size limit. 0 = infinite.
  • allowcontrol – if True, the connector accepts ConnectorControlEvent for connector configuration.
main()

The main routine method, should be rewritten to an async method

class vlcp.utils.connector.ConnectorControlEvent(*args, **kwargs)
class vlcp.utils.connector.MoreResultEvent(*args, **kwargs)
class vlcp.utils.connector.Resolver(scheduler=None, poolsize=256)
__init__(scheduler=None, poolsize=256)
Parameters:
  • worker_start – func(queuein, queueout), queuein is the input queue, queueout is the output queue. For queuein, each object is (event, matcher) tuple; For queueout, each object is a tuple of events to send. Every object in queuein must have a response in queueout.
  • matcheres – match events to be processed by connector.
  • scheduler – bind to specified scheduler
  • mp – use multiprocessing if possible. For windows, multi-threading is always used.
  • inputlimit – input queue size limit. 0 = infinite.
  • allowcontrol – if True, the connector accepts ConnectorControlEvent for connector configuration.
class vlcp.utils.connector.TaskDoneEvent(*args, **kwargs)
class vlcp.utils.connector.TaskEvent(*args, **kwargs)
class vlcp.utils.connector.TaskPool(scheduler=None, poolsize=64)

Thread pool for small tasks

__init__(scheduler=None, poolsize=64)
Parameters:
  • worker_start – func(queuein, queueout), queuein is the input queue, queueout is the output queue. For queuein, each object is (event, matcher) tuple; For queueout, each object is a tuple of events to send. Every object in queuein must have a response in queueout.
  • matcheres – match events to be processed by connector.
  • scheduler – bind to specified scheduler
  • mp – use multiprocessing if possible. For windows, multi-threading is always used.
  • inputlimit – input queue size limit. 0 = infinite.
  • allowcontrol – if True, the connector accepts ConnectorControlEvent for connector configuration.
runAsyncTask(container, asynctask, newthread=True)

Run asynctask(sender) in task pool, call sender(events) to send customized events, return result

runGenTask(container, gentask, newthread=True)

Run generator gentask() in task pool, yield customized events

runTask(container, task, newthread=False)

Run task() in task pool. Raise an exception or return the return value

run_async_task(container, asynctask, newthread=True)

Run asynctask(sender) in task pool, call sender(events) to send customized events, return result

run_gen_task(container, gentask, newthread=True)

Run generator gentask() in task pool, yield customized events

run_task(container, task, newthread=False)

Run task() in task pool. Raise an exception or return the return value