Python asyncio.SelectorEventLoop() Examples
The following are 30
code examples of asyncio.SelectorEventLoop().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
asyncio
, or try the search function
.
Example #1
Source File: od_watcher.py From onedrived-dev with MIT License | 6 votes |
def __init__(self, task_pool, loop=None): """ :param onedrived.od_task.TaskPool task_pool: :param asyncio.SelectorEventLoop | None loop: """ self._lock = threading.RLock() self.watch_descriptors = loosebidict() self.task_queue = [] self.task_pool = task_pool self.notifier = _INotify() if loop is None: import asyncio self.loop = asyncio.get_event_loop() else: self.loop = loop self.loop.add_reader(self.notifier.fd, self.process_events)
Example #2
Source File: loop.py From kitty with GNU General Public License v3.0 | 6 votes |
def __init__( self, sanitize_bracketed_paste: str = '[\x03\x04\x0e\x0f\r\x07\x7f\x8d\x8e\x8f\x90\x9b\x9d\x9e\x9f]' ): if is_macos: # On macOS PTY devices are not supported by the KqueueSelector and # the PollSelector is broken, causes 100% CPU usage self.asycio_loop: asyncio.AbstractEventLoop = asyncio.SelectorEventLoop(selectors.SelectSelector()) asyncio.set_event_loop(self.asycio_loop) else: self.asycio_loop = asyncio.get_event_loop() self.return_code = 0 self.read_buf = '' self.decoder = codecs.getincrementaldecoder('utf-8')('ignore') try: self.iov_limit = max(os.sysconf('SC_IOV_MAX') - 1, 255) except Exception: self.iov_limit = 255 self.parse_input_from_terminal = partial(parse_input_from_terminal, self._on_text, self._on_dcs, self._on_csi, self._on_osc, self._on_pm, self._on_apc) self.ebs_pat = re.compile('([\177\r\x03\x04])') self.in_bracketed_paste = False self.sanitize_bracketed_paste = bool(sanitize_bracketed_paste) if self.sanitize_bracketed_paste: self.sanitize_ibp_pat = re.compile(sanitize_bracketed_paste)
Example #3
Source File: dialogs.py From pychess with GNU General Public License v3.0 | 6 votes |
def setUp(self): if sys.platform == "win32": from asyncio.windows_events import ProactorEventLoop loop = ProactorEventLoop() asyncio.set_event_loop(loop) else: loop = asyncio.SelectorEventLoop() asyncio.set_event_loop(loop) self.loop = asyncio.get_event_loop() self.loop.set_debug(enabled=True) widgets = uistuff.GladeWidgets("PyChess.glade") gamewidget.setWidgets(widgets) perspective_manager.set_widgets(widgets) self.welcome_persp = Welcome() perspective_manager.add_perspective(self.welcome_persp) self.games_persp = Games() perspective_manager.add_perspective(self.games_persp)
Example #4
Source File: test_unix_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def setUp(self): super().setUp() self.loop = asyncio.SelectorEventLoop() self.set_event_loop(self.loop)
Example #5
Source File: test_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop(selectors.SelectSelector())
Example #6
Source File: test_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop(selectors.PollSelector()) # Should always exist.
Example #7
Source File: test_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop(selectors.EpollSelector())
Example #8
Source File: test_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop( selectors.KqueueSelector()) # kqueue doesn't support character devices (PTY) on Mac OS X older # than 10.9 (Maverick)
Example #9
Source File: test_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop()
Example #10
Source File: _unix.py From asyncqt with BSD 2-Clause "Simplified" License | 5 votes |
def __init__(self): self._signal_safe_callbacks = [] selector = _Selector(self) asyncio.SelectorEventLoop.__init__(self, selector)
Example #11
Source File: inputhook.py From python-prompt-toolkit with BSD 3-Clause "New" or "Revised" License | 5 votes |
def new_eventloop_with_inputhook( inputhook: Callable[["InputHookContext"], None] ) -> AbstractEventLoop: """ Create a new event loop with the given inputhook. """ selector = InputHookSelector(selectors.DefaultSelector(), inputhook) loop = asyncio.SelectorEventLoop(selector) return loop
Example #12
Source File: test_unix_events.py From annotated-py-projects with MIT License | 5 votes |
def setUp(self): self.loop = asyncio.SelectorEventLoop() self.set_event_loop(self.loop)
Example #13
Source File: test_unix_events.py From annotated-py-projects with MIT License | 5 votes |
def setUp(self): self.loop = asyncio.SelectorEventLoop() self.set_event_loop(self.loop)
Example #14
Source File: test_events.py From annotated-py-projects with MIT License | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop(selectors.PollSelector()) # Should always exist.
Example #15
Source File: test_events.py From annotated-py-projects with MIT License | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop(selectors.EpollSelector())
Example #16
Source File: test_events.py From annotated-py-projects with MIT License | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop( selectors.KqueueSelector()) # kqueue doesn't support character devices (PTY) on Mac OS X older # than 10.9 (Maverick)
Example #17
Source File: test_server.py From android_universal with MIT License | 5 votes |
def new_loop(self): return asyncio.SelectorEventLoop()
Example #18
Source File: test_events.py From annotated-py-projects with MIT License | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop()
Example #19
Source File: crawl.py From annotated-py-projects with MIT License | 5 votes |
def main(): """Main program. Parse arguments, set up event loop, run crawler, print report. """ args = ARGS.parse_args() if not args.roots: print('Use --help for command line help') return log = Logger(args.level) if args.iocp: from asyncio.windows_events import ProactorEventLoop loop = ProactorEventLoop() asyncio.set_event_loop(loop) elif args.select: loop = asyncio.SelectorEventLoop() asyncio.set_event_loop(loop) else: loop = asyncio.get_event_loop() roots = {fix_url(root) for root in args.roots} crawler = Crawler(log, roots, exclude=args.exclude, strict=args.strict, max_redirect=args.max_redirect, max_tries=args.max_tries, max_tasks=args.max_tasks, max_pool=args.max_pool, ) try: loop.run_until_complete(crawler.crawl()) # Crawler gonna crawl. except KeyboardInterrupt: sys.stderr.flush() print('\nInterrupted\n') finally: crawler.report() crawler.close() loop.close()
Example #20
Source File: selector.py From asynctest with Apache License 2.0 | 5 votes |
def set_write_ready(fileobj, loop): """ Schedule callbacks registered on ``loop`` as if the selector notified that data can be written to ``fileobj``. :param fileobj: file object or :class:`~asynctest.FileMock` on which th event is mocked. :param loop: :class:`asyncio.SelectorEventLoop` watching for events on ``fileobj``. .. versionadded:: 0.4 """ loop.call_soon_threadsafe(_set_event_ready, fileobj, loop, selectors.EVENT_WRITE)
Example #21
Source File: selector.py From asynctest with Apache License 2.0 | 5 votes |
def set_read_ready(fileobj, loop): """ Schedule callbacks registered on ``loop`` as if the selector notified that data is ready to be read on ``fileobj``. :param fileobj: file object or :class:`~asynctest.FileMock` on which the event is mocked. :param loop: :class:`asyncio.SelectorEventLoop` watching for events on ``fileobj``. :: mock = asynctest.SocketMock() mock.recv.return_value = b"Data" def read_ready(sock): print("received:", sock.recv(1024)) loop.add_reader(mock, read_ready, mock) set_read_ready(mock, loop) loop.run_forever() # prints received: b"Data" .. versionadded:: 0.4 """ # since the selector would notify of events at the beginning of the next # iteration, we let this iteration finish before actually scheduling the # reader (hence the call_soon) loop.call_soon_threadsafe(_set_event_ready, fileobj, loop, selectors.EVENT_READ)
Example #22
Source File: test_unix_events.py From ironpython3 with Apache License 2.0 | 5 votes |
def setUp(self): self.loop = asyncio.SelectorEventLoop() self.set_event_loop(self.loop)
Example #23
Source File: test_events.py From ironpython3 with Apache License 2.0 | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop(selectors.SelectSelector())
Example #24
Source File: test_events.py From ironpython3 with Apache License 2.0 | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop(selectors.PollSelector()) # Should always exist.
Example #25
Source File: test_events.py From ironpython3 with Apache License 2.0 | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop(selectors.EpollSelector())
Example #26
Source File: test_events.py From ironpython3 with Apache License 2.0 | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop( selectors.KqueueSelector()) # kqueue doesn't support character devices (PTY) on Mac OS X older # than 10.9 (Maverick)
Example #27
Source File: test_events.py From ironpython3 with Apache License 2.0 | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop()
Example #28
Source File: test_unix_events.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def setUp(self): self.loop = asyncio.SelectorEventLoop() self.set_event_loop(self.loop)
Example #29
Source File: test_events.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop(selectors.SelectSelector())
Example #30
Source File: test_events.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def create_event_loop(self): return asyncio.SelectorEventLoop(selectors.PollSelector()) # Should always exist.