本文整理汇总了Python中twisted.internet.task.LoopingCall.withCount方法的典型用法代码示例。如果您正苦于以下问题:Python LoopingCall.withCount方法的具体用法?Python LoopingCall.withCount怎么用?Python LoopingCall.withCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.task.LoopingCall
的用法示例。
在下文中一共展示了LoopingCall.withCount方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import withCount [as 别名]
def __init__(self, *args, **kwargs):
self.dead = False
self.type = None
self.secure = False
self.data = 0
self.data_checker = LoopingCall(self.checkData)
self.pinger = LoopingCall.withCount(self.ping)
示例2: __init__
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import withCount [as 别名]
def __init__(
self, reactor, request, request_rate=10,
sample_size=DEFAULT_SAMPLE_SIZE, timeout=45,
tolerance_percentage=0.2
):
"""
``RequestLoadScenario`` constructor.
:param tolerance_percentage: error percentage in the rate that is
considered valid. For example, if we request a ``request_rate``
of 20, and we give a tolerance_percentage of 0.2 (20%), anything
in [16,20] will be a valid rate.
"""
self.reactor = reactor
self.request = request
self.request_rate = request_rate
self.timeout = timeout
self._maintained = Deferred()
self.rate_measurer = RateMeasurer(sample_size)
self.max_outstanding = 10 * request_rate
self.tolerated_errors = 5 * request_rate
# Send requests per second
self.loop = LoopingCall.withCount(self._request_and_measure)
self.loop.clock = self.reactor
# Monitor the status of the scenario
self.monitor_loop = LoopingCall(self.check_rate)
self.monitor_loop.clock = self.reactor
self.is_started = False
self.rate_tolerated = (
float(request_rate) - (request_rate*tolerance_percentage)
)
示例3: start
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import withCount [as 别名]
def start(self):
"""
Start the simulated advancement of time.
"""
self._call = LoopingCall.withCount(self._update)
self._call.clock = self.platformClock
self._call.start(1.0 / self.granularity, now=False)
示例4: start
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import withCount [as 别名]
def start(self):
"""
Start the simulated advancement of time.
"""
self._call = LoopingCall.withCount(self._update)
self._call.clock = reactor
self._call.start(1.0 / self.framerate, now=False)
self._running = True
示例5: __init__
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import withCount [as 别名]
def __init__(self, ip):
self.dead = False
self.type = None
self.secure = False
self.data = 0
self.data_checker = LoopingCall(self.checkData)
self.pinger = LoopingCall.withCount(self.ping)
self.connection_expire = reactor.callLater(15, self.connectionLost, None)
self.ip = ip
示例6: configure
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import withCount [as 别名]
def configure(self, config):
room = self.original
self._loop = LoopingCall.withCount(self.update)
self._interval = 0.1
self.map, self.walk = gen_map()
self.tick = 0
self.enemies = []
self.towers = []
self.spawned = 0
self.stats = defaultdict(int)
示例7: __init__
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import withCount [as 别名]
def __init__(
self, reactor, cluster, request_rate=10,
sample_size=DEFAULT_SAMPLE_SIZE, timeout=45
):
self._maintained = Deferred()
self.reactor = reactor
self.control_service = cluster.get_control_service(reactor)
self.request_rate = request_rate
self.timeout = timeout
self.rate_measurer = RateMeasurer(sample_size)
self.max_outstanding = 10 * request_rate
# Send requests per second
self.loop = LoopingCall.withCount(self._request_and_measure)
self.loop.clock = self.reactor
self.monitor_loop = LoopingCall(self.check_rate)
self.monitor_loop.clock = self.reactor
示例8: __init__
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import withCount [as 别名]
def __init__(
self, reactor, cluster, request_rate=10,
sample_size=DEFAULT_SAMPLE_SIZE, timeout=45
):
self._maintained = Deferred()
self.reactor = reactor
self.control_service = cluster.get_control_service(reactor)
self.request_rate = request_rate
self.timeout = timeout
self.rate_measurer = RateMeasurer(sample_size)
self.max_outstanding = 10 * request_rate
self._dataset_id = ""
# Send requests per second
self.loop = LoopingCall.withCount(self._request_and_measure)
self.loop.clock = self.reactor
# Once the expected rate is reached, we will start monitoring
# the scenario inside this loop
self.monitor_loop = LoopingCall(self.check_rate)
self.monitor_loop.clock = self.reactor
示例9: __init__
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import withCount [as 别名]
def __init__(
self, reactor, scenario_setup_instance, request_rate=10,
sample_size=DEFAULT_SAMPLE_SIZE, timeout=45,
tolerance_percentage=0.2
):
"""
``RequestLoadScenario`` constructor.
:param reactor: Reactor to use.
:param scenario_setup_instance: provider of the
``IRequestScenarioSetup`` interface.
:param request_rate: target number of request per second.
:param sample_size: number of samples to collect when measuring
the rate.
:param tolerance_percentage: error percentage in the rate that is
considered valid. For example, if we request a ``request_rate``
of 20, and we give a tolerance_percentage of 0.2 (20%), anything
in [16,20] will be a valid rate.
"""
self.reactor = reactor
self.scenario_setup = scenario_setup_instance
self.request_rate = request_rate
self.timeout = timeout
self._maintained = Deferred()
self.rate_measurer = RateMeasurer(sample_size)
self.max_outstanding = 10 * request_rate
# Send requests per second
self.loop = LoopingCall.withCount(self._request_and_measure)
self.loop.clock = self.reactor
# Monitor the status of the scenario
self.monitor_loop = LoopingCall(self.check_rate)
self.monitor_loop.clock = self.reactor
self.is_started = False
self.rate_tolerated = (
float(request_rate) - (request_rate*tolerance_percentage)
)
示例10: __init__
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import withCount [as 别名]
def __init__(self, *args, **kwargs):
super(Furnace, self).__init__(*args, **kwargs)
self.inventory = FurnaceStorage()
self.burning = LoopingCall.withCount(self.burn)
示例11: __init__
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import withCount [as 别名]
def __init__(self, delay=0.01):
self.delay = delay
self.loop_call = LoopingCall.withCount(self.watch)
self.blocked = 0
self.checks = []
self.d = None
示例12: __init__
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import withCount [as 别名]
def __init__(self, tile, coords):
self.tile = tile
self.coords = coords
self.running = False
self.burning = LoopingCall.withCount(self.burn)