settings module

配置

date:2014-12-26
author:刘雪彦 <lxy@hesong.net>
settings.EXECUTOR_CONFIG = {'pool_processes': 1, 'queue_maxsize': 1000, 'pool_maxtasksperchild': 1000}

执行器设置

这个设置被用于 executor.Executor 构造函数的传入参数。

参数:
  • queue_maxsize – 任务队列最大值。0,表示无限制。
  • pool_processes – 执行器池的最大数量。 None 表示使用 CPU 核心数量作为其最大值。
  • pool_maxtasksperchild – 进程池最大执行数量。 None 表示无限制。超过该值,则重启子进程。

警告

不得删除该变量,不得修改该变量的结构。

settings.FLOW_ACK_TIMEOUT = 15

流程调用时等待调用结果的最大时间,单位是秒

settings.LOGGING_CONFIG = {'handlers': {'consoleErr': {'class': 'logging.StreamHandler', 'formatter': 'normal', 'level': 'ERROR', 'stream': 'ext://sys.stderr'}, 'smartbusFile': {'class': 'logging.handlers.RotatingFileHandler', 'formatter': 'normal', 'backupCount': 1000, 'maxBytes': 10485760, 'filename': '../logs/smartbus'}, 'fileErr': {'class': 'logging.handlers.RotatingFileHandler', 'level': 'ERROR', 'formatter': 'normal', 'backupCount': 1000, 'maxBytes': 10485760, 'filename': '../logs/err'}, 'console': {'class': 'logging.StreamHandler', 'formatter': 'normal', 'stream': 'ext://sys.stdout'}, 'file': {'class': 'logging.handlers.RotatingFileHandler', 'level': 'DEBUG', 'formatter': 'normal', 'backupCount': 1000, 'maxBytes': 10485760, 'filename': '../logs/log'}}, 'loggers': {'smartbus.netclient.client.Client': {'handlers': ['smartbusFile'], 'level': 'INFO'}, 'smartbus.ipcclient.client.Client': {'handlers': ['smartbusFile'], 'level': 'INFO'}}, 'formatters': {'normal': {'format': '%(asctime)s <%(processName)-10s,%(threadName)-10s> %(levelname)-8s %(name)s - %(message)s'}}, 'version': 1, 'root': {'handlers': ['console', 'file', 'fileErr'], 'level': 'INFO'}}

日志设置

其格式请参考: https://docs.python.org/2/library/logging.config.html#configuration-dictionary-schemahttps://docs.python.org/3/library/logging.config.html#configuration-dictionary-schema

settings.SMARTBUS_CONFIG = {'type': 'net', 'clients': [{'extInfo': None, 'authorUsr': None, 'slaverPort': 0, 'localClientId': 0, 'masterHost': '10.4.62.45', 'localClientType': 19, 'encoding': 'utf-8', 'masterPort': 8089, 'authorPwd': None, 'slaverHost': None}], 'initialize': {'unitid': 19}}

SmartBus客户端配置

参数:
  • type

    smartbus客户端类型,有效值:"net""ipc"

    • "net" : 使用smartbus网络通信客户端
    • "ipc" : 使用smartbus进程通信客户端
  • initialize

    smartbus客户端模块初始化参数属性字段

    • type 属性为 "net" 时,该属性必须设置一个属性 unitid
    • type 属性为 "ipc" 时,该属性必须设置两个属性 clientidclienttype

    具体含义请参考 smartbus 文档

  • instance

    smartbus进程通信客户端地址参数属性字段

    该 dict 属性需要设置3个属性:

    • username
    • password
    • extInfo

    具体含义请参考 smartbus 文档

    注意

    仅当 type 属性为 "ipc" 时有效

  • clients

    smartbus网络通信客户端地址参数属性字段

    该 list 属性的每个成员表示一个smartbus网络通信客户端,每个客户端的参数都是:

    • localClientId
    • localClientType
    • masterHost
    • masterPort
    • slaverHost
    • slaverPort
    • authorUsr
    • authorPwd
    • extInfo

    具体含义请参考 smartbus 文档

    注意

    仅当 type 属性为 "net" 时有效

settings.SMARTBUS_NOTIFY_TTL = 10000

通过smartbus发送给IPSC流程的notify消息的生存期(ms)

settings.WEBSERVER_LISTEN = (8080, '')

WEB 服务器监听端口与地址.

格式是:

(port, address)

警告

不得删除该变量,不得修改该变量的结构。