diff --git a/uvloop/__init__.py b/uvloop/__init__.py index f37c69e..49c8d44 100644 --- a/uvloop/__init__.py +++ b/uvloop/__init__.py @@ -1,4 +1,4 @@ -import asyncio +import asyncio as __asyncio from asyncio.events import BaseDefaultEventLoopPolicy as __BasePolicy @@ -8,10 +8,10 @@ from .loop import Loop as __BaseLoop # NOQA __version__ = '0.12.0.dev0' -__all__ = ('new_event_loop', 'EventLoopPolicy') +__all__ = ('new_event_loop', 'install', 'EventLoopPolicy') -class Loop(__BaseLoop, asyncio.AbstractEventLoop): +class Loop(__BaseLoop, __asyncio.AbstractEventLoop): pass @@ -20,6 +20,11 @@ def new_event_loop(): return Loop() +def install(): + """A helper function to install uvloop policy.""" + __asyncio.set_event_loop_policy(EventLoopPolicy()) + + class EventLoopPolicy(__BasePolicy): """Event loop policy.