Esempio n. 1
0
def test_jobscheduler_stop(mockconfig, botfactory):
    mockbot = botfactory(mockconfig)
    scheduler = jobs.Scheduler(mockbot)
    assert not scheduler.stopping.is_set(), 'Stopping must not be set at init'

    scheduler.stop()
    assert scheduler.stopping.is_set(), 'Stopping must have been set'
Esempio n. 2
0
    def __init__(self, bot, server_timeout=None, ping_interval=None, **kwargs):
        AbstractIRCBackend.__init__(self, bot)
        asynchat.async_chat.__init__(self)
        self.writing_lock = threading.RLock()
        self.set_terminator(b'\r\n')
        self.buffer = ''
        self.server_timeout = server_timeout or 120
        self.ping_interval = ping_interval or (self.server_timeout * 0.45)
        self.last_event_at = None
        self.last_ping_at = None
        self.host = None
        self.port = None
        self.source_address = None
        self.timeout_scheduler = jobs.Scheduler(self)

        # register timeout jobs
        self.register_timeout_jobs([
            (5, _send_ping),
            (10, _check_timeout),
        ])
Esempio n. 3
0
    def __init__(self, bot, server_timeout=None, ping_timeout=None, **kwargs):
        AbstractIRCBackend.__init__(self, bot)
        asynchat.async_chat.__init__(self)
        self.writing_lock = threading.RLock()
        self.set_terminator(b'\n')
        self.buffer = ''
        self.server_timeout = server_timeout or 120
        self.ping_timeout = ping_timeout or (self.server_timeout / 2)
        self.last_event_at = None
        self.host = None
        self.port = None
        self.source_address = None
        self.timeout_scheduler = jobs.Scheduler(self)

        # prepare interval decorator
        ping_interval = plugin.interval(self.ping_timeout)
        timeout_interval = plugin.interval(self.server_timeout)

        # register timeout jobs
        self.register_timeout_jobs([
            ping_interval(_send_ping),
            timeout_interval(_check_timeout),
        ])