25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

42 lines
965 B

  1. import asyncio as __asyncio
  2. from asyncio.events import BaseDefaultEventLoopPolicy as __BasePolicy
  3. from . import includes as __includes # NOQA
  4. from . import _patch # NOQA
  5. from .loop import Loop as __BaseLoop # NOQA
  6. __version__ = '0.13.0'
  7. __all__ = ('new_event_loop', 'install', 'EventLoopPolicy')
  8. class Loop(__BaseLoop, __asyncio.AbstractEventLoop):
  9. pass
  10. def new_event_loop():
  11. """Return a new event loop."""
  12. return Loop()
  13. def install():
  14. """A helper function to install uvloop policy."""
  15. __asyncio.set_event_loop_policy(EventLoopPolicy())
  16. class EventLoopPolicy(__BasePolicy):
  17. """Event loop policy.
  18. The preferred way to make your application use uvloop:
  19. >>> import asyncio
  20. >>> import uvloop
  21. >>> asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
  22. >>> asyncio.get_event_loop()
  23. <uvloop.Loop running=False closed=False debug=False>
  24. """
  25. def _loop_factory(self):
  26. return new_event_loop()