Skip to content

Commit a3d8d40

Browse files
committed
Add uvloop.install() helper function.
1 parent f24c822 commit a3d8d40

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

uvloop/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import asyncio
1+
import asyncio as __asyncio
22

33
from asyncio.events import BaseDefaultEventLoopPolicy as __BasePolicy
44

@@ -8,10 +8,10 @@
88

99

1010
__version__ = '0.12.0.dev0'
11-
__all__ = ('new_event_loop', 'EventLoopPolicy')
11+
__all__ = ('new_event_loop', 'install', 'EventLoopPolicy')
1212

1313

14-
class Loop(__BaseLoop, asyncio.AbstractEventLoop):
14+
class Loop(__BaseLoop, __asyncio.AbstractEventLoop):
1515
pass
1616

1717

@@ -20,6 +20,11 @@ def new_event_loop():
2020
return Loop()
2121

2222

23+
def install():
24+
"""A helper function to install uvloop policy."""
25+
__asyncio.set_event_loop_policy(EventLoopPolicy())
26+
27+
2328
class EventLoopPolicy(__BasePolicy):
2429
"""Event loop policy.
2530

0 commit comments

Comments
 (0)