commit: 20204fd8c29f3060da9891879721a54486247b0c Author: Zac Medico <zmedico <AT> gentoo <DOT> org> AuthorDate: Sun Mar 7 07:44:49 2021 +0000 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> CommitDate: Sun Mar 7 07:45:11 2021 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=20204fd8
Remove unused _PortageEventLoop and _PortageChildWatcher Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> lib/portage/util/futures/unix_events.py | 112 -------------------------------- 1 file changed, 112 deletions(-) diff --git a/lib/portage/util/futures/unix_events.py b/lib/portage/util/futures/unix_events.py index 030070b1b..4feee0a3b 100644 --- a/lib/portage/util/futures/unix_events.py +++ b/lib/portage/util/futures/unix_events.py @@ -18,61 +18,6 @@ from portage.util._eventloop.global_event_loop import ( ) -class _PortageEventLoop(events.AbstractEventLoop): - """ - Implementation of asyncio.AbstractEventLoop which wraps portage's - internal event loop. - """ - - def __init__(self, loop): - """ - @type loop: EventLoop - @param loop: an instance of portage's internal event loop - """ - self._loop = loop - self.run_until_complete = loop.run_until_complete - self.call_soon = loop.call_soon - self.call_soon_threadsafe = loop.call_soon_threadsafe - self.call_later = loop.call_later - self.call_at = loop.call_at - self.is_running = loop.is_running - self.is_closed = loop.is_closed - self.close = loop.close - self.create_future = loop.create_future - self.add_reader = loop.add_reader - self.remove_reader = loop.remove_reader - self.add_writer = loop.add_writer - self.remove_writer = loop.remove_writer - self.run_in_executor = loop.run_in_executor - self.time = loop.time - self.default_exception_handler = loop.default_exception_handler - self.call_exception_handler = loop.call_exception_handler - self.set_debug = loop.set_debug - self.get_debug = loop.get_debug - - @property - def _asyncio_child_watcher(self): - """ - In order to avoid accessing the internal _loop attribute, portage - internals should use this property when possible. - - @rtype: asyncio.AbstractChildWatcher - @return: the internal event loop's AbstractChildWatcher interface - """ - return self._loop._asyncio_child_watcher - - @property - def _asyncio_wrapper(self): - """ - In order to avoid accessing the internal _loop attribute, portage - internals should use this property when possible. - - @rtype: asyncio.AbstractEventLoop - @return: the internal event loop's AbstractEventLoop interface - """ - return self - - if hasattr(os, 'set_blocking'): def _set_nonblocking(fd): os.set_blocking(fd, False) @@ -83,63 +28,6 @@ else: fcntl.fcntl(fd, fcntl.F_SETFL, flags) -class _PortageChildWatcher(AbstractChildWatcher): - def __init__(self, loop): - """ - @type loop: EventLoop - @param loop: an instance of portage's internal event loop - """ - self._loop = loop - self._callbacks = {} - - def close(self): - pass - - def __enter__(self): - return self - - def __exit__(self, a, b, c): - pass - - def _child_exit(self, pid, status, data): - self._callbacks.pop(pid) - callback, args = data - callback(pid, self._compute_returncode(status), *args) - - def _compute_returncode(self, status): - if os.WIFSIGNALED(status): - return -os.WTERMSIG(status) - if os.WIFEXITED(status): - return os.WEXITSTATUS(status) - return status - - def add_child_handler(self, pid, callback, *args): - """ - Register a new child handler. - - Arrange for callback(pid, returncode, *args) to be called when - process 'pid' terminates. Specifying another callback for the same - process replaces the previous handler. - """ - source_id = self._callbacks.get(pid) - if source_id is not None: - self._loop.source_remove(source_id) - self._callbacks[pid] = self._loop.child_watch_add( - pid, self._child_exit, data=(callback, args)) - - def remove_child_handler(self, pid): - """ - Removes the handler for process 'pid'. - - The function returns True if the handler was successfully removed, - False if there was nothing to remove. - """ - source_id = self._callbacks.pop(pid, None) - if source_id is not None: - return self._loop.source_remove(source_id) - return False - - class _PortageEventLoopPolicy(events.AbstractEventLoopPolicy): """ Implementation of asyncio.AbstractEventLoopPolicy based on portage's