Add `uvloop.install()` helper function.

This commit is contained in:
Yury Selivanov 2018-08-02 10:58:36 -04:00
parent f24c8223b9
commit a3d8d4011f
1 changed files with 8 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import asyncio import asyncio as __asyncio
from asyncio.events import BaseDefaultEventLoopPolicy as __BasePolicy from asyncio.events import BaseDefaultEventLoopPolicy as __BasePolicy
@ -8,10 +8,10 @@ from .loop import Loop as __BaseLoop # NOQA
__version__ = '0.12.0.dev0' __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 pass
@ -20,6 +20,11 @@ def new_event_loop():
return Loop() return Loop()
def install():
"""A helper function to install uvloop policy."""
__asyncio.set_event_loop_policy(EventLoopPolicy())
class EventLoopPolicy(__BasePolicy): class EventLoopPolicy(__BasePolicy):
"""Event loop policy. """Event loop policy.