craftbeerpi4-pione/core/job/__init__.py

23 lines
829 B
Python
Raw Normal View History

2018-11-18 15:40:10 +01:00
"""Jobs scheduler for managing background task (asyncio).
The library gives controlled way for scheduling background tasks for
asyncio applications.
"""
__version__ = '0.2.2'
import asyncio
from ._scheduler import Scheduler
2018-11-30 23:27:11 +01:00
async def create_scheduler(cbpi,*, close_timeout=0.1, limit=100,
2018-11-18 15:40:10 +01:00
pending_limit=10000, exception_handler=None):
if exception_handler is not None and not callable(exception_handler):
raise TypeError('A callable object or None is expected, '
'got {!r}'.format(exception_handler))
loop = asyncio.get_event_loop()
2018-11-30 23:27:11 +01:00
return Scheduler(cbpi=cbpi,loop=loop, close_timeout=close_timeout,
2018-11-18 15:40:10 +01:00
limit=limit, pending_limit=pending_limit,
exception_handler=exception_handler)
__all__ = ('create_scheduler',)