How to use the aiocron.crontab function in aiocron

To help you get started, we’ve selected a few aiocron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gawel / aiocron / tests / test_cron.py View on Github external
    @crontab('* * * * * *', loop=loop)
    @asyncio.coroutine
    def t():
        raise CustomError()
github gawel / aiocron / tests / test_cron.py View on Github external
    @crontab('* * * * * *', start=False, loop=loop)
    def t():
        loop.call_later(1, future.set_result, 1)
        raise ValueError()
github gawel / aiocron / tests / test_cron.py View on Github external
def test_next():
    loop = asyncio.new_event_loop()

    def t():
        return 1

    t = crontab('* * * * * *', func=t, loop=loop)

    future = asyncio.ensure_future(t.next(), loop=loop)

    loop.run_until_complete(future)
    assert future.result() == 1
github satanowski / rpi0watch / src / main.py View on Github external
@aiocron.crontab('*/{} * * * *'.format(CHECK_INTERVAL))
@asyncio.coroutine
def check():
    """Check availability of all observed products."""
    global last_check

    for shop in SHOP_HANDLERS:
        yield from shop.check()

    last_check = datetime.utcnow().strftime("%Y/%m/%d-%H:%M")

    if any([shop.available for shop in SHOP_HANDLERS]):
        log.info('In stock!')
        availability.append(True)
        yield from notify()
    else:
        log.info('Out of stock')
github gawel / aiocron / examples / threaded.py View on Github external
def crontab(self, *args, **kwargs):
        kwargs['loop'] = self.loop
        return aiocron.crontab(*args, **kwargs)
github FAForever / server / server / game_service.py View on Github external
async def initialize(self) -> None:
        await self.initialise_game_counter()
        await self.update_data()
        self._update_cron = aiocron.crontab(
            '*/10 * * * *', func=self.update_data
        )

        await self._message_queue_service.declare_exchange("faf-rabbitmq")
github FAForever / server / server / geoip_service.py View on Github external
async def initialize(self) -> None:
        await self.check_update_geoip_db()
        # crontab: min hour day month day_of_week
        # Run every Wednesday because GeoLite2 is updated every first Tuesday
        # of the month.
        self._update_cron = aiocron.crontab(
            '0 0 0 * * 3', func=self.check_update_geoip_db
        )
        self._check_file_timer = Timer(
            60 * 10, self.check_geoip_db_file_updated, start=True
        )
github FAForever / server / server / rating_service / rating_service.py View on Github external
async def initialize(self) -> None:
        if self._task is not None:
            self._logger.error("Service already runnning or not properly shut down.")
            return

        await self.update_data()
        self._update_cron = aiocron.crontab("*/10 * * * *", func=self.update_data)
        self._accept_input = True
        self._logger.debug("RatingService starting...")
        self._task = asyncio.create_task(self._handle_rating_queue())
github FAForever / server / server / player_service.py View on Github external
async def initialize(self) -> None:
        await self.update_data()
        self._update_cron = aiocron.crontab(
            '*/10 * * * *', func=self.update_data
        )
github FAForever / server / server / ladder_service.py View on Github external
async def initialize(self) -> None:
        # TODO: Starting hardcoded queues here
        for queue in self.queues.values():
            queue.initialize()

        await self.update_data()
        self._update_cron = aiocron.crontab('*/10 * * * *', func=self.update_data)

        self.start_queue_handlers()

aiocron

Crontabs for asyncio

MIT
Latest version published 2 years ago

Package Health Score

52 / 100
Full package analysis

Similar packages