generated from daniil-berg/boilerplate-py
moved control-related modules to a sub-package; minor corrections
This commit is contained in:
parent
c72a5035ea
commit
9fde231250
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = asyncio-taskpool
|
||||
version = 0.6.0
|
||||
version = 0.6.1
|
||||
author = Daniil Fajnberg
|
||||
author_email = mail@daniil.fajnberg.de
|
||||
description = Dynamically manage pools of asyncio tasks
|
||||
|
@ -19,5 +19,5 @@ Brings the main classes up to package level for import convenience.
|
||||
"""
|
||||
|
||||
|
||||
from .control.server import TCPControlServer, UnixControlServer
|
||||
from .pool import TaskPool, SimpleTaskPool
|
||||
from .server import TCPControlServer, UnixControlServer
|
||||
|
0
src/asyncio_taskpool/control/__init__.py
Normal file
0
src/asyncio_taskpool/control/__init__.py
Normal file
@ -25,9 +25,9 @@ from asyncio import run
|
||||
from pathlib import Path
|
||||
from typing import Dict, Any
|
||||
|
||||
from ..constants import PACKAGE_NAME
|
||||
from ..pool import TaskPool
|
||||
from .client import ControlClient, TCPControlClient, UnixControlClient
|
||||
from .constants import PACKAGE_NAME
|
||||
from .pool import TaskPool
|
||||
from .server import TCPControlServer, UnixControlServer
|
||||
|
||||
|
@ -27,8 +27,8 @@ from asyncio.streams import StreamReader, StreamWriter, open_connection
|
||||
from pathlib import Path
|
||||
from typing import Optional, Union
|
||||
|
||||
from .constants import CLIENT_EXIT, CLIENT_INFO, SESSION_MSG_BYTES
|
||||
from .types import ClientConnT, PathT
|
||||
from ..constants import CLIENT_EXIT, CLIENT_INFO, SESSION_MSG_BYTES
|
||||
from ..types import ClientConnT, PathT
|
||||
|
||||
|
||||
class ControlClient(ABC):
|
@ -25,9 +25,9 @@ from inspect import Parameter, getmembers, isfunction, signature
|
||||
from shutil import get_terminal_size
|
||||
from typing import Callable, Container, Dict, Set, Type, TypeVar
|
||||
|
||||
from .constants import CLIENT_INFO, CMD, STREAM_WRITER
|
||||
from .exceptions import HelpRequested
|
||||
from .helpers import get_first_doc_line
|
||||
from ..constants import CLIENT_INFO, CMD, STREAM_WRITER
|
||||
from ..exceptions import HelpRequested
|
||||
from ..helpers import get_first_doc_line
|
||||
|
||||
|
||||
FmtCls = TypeVar('FmtCls', bound=Type[HelpFormatter])
|
@ -28,10 +28,10 @@ from asyncio.tasks import Task, create_task
|
||||
from pathlib import Path
|
||||
from typing import Optional, Union
|
||||
|
||||
from ..pool import TaskPool, SimpleTaskPool
|
||||
from ..types import ConnectedCallbackT
|
||||
from .client import ControlClient, TCPControlClient, UnixControlClient
|
||||
from .pool import TaskPool, SimpleTaskPool
|
||||
from .session import ControlSession
|
||||
from .types import ConnectedCallbackT
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
@ -26,10 +26,10 @@ from asyncio.streams import StreamReader, StreamWriter
|
||||
from inspect import isfunction, signature
|
||||
from typing import Callable, Optional, Union, TYPE_CHECKING
|
||||
|
||||
from .constants import CLIENT_INFO, CMD, CMD_OK, SESSION_MSG_BYTES, STREAM_WRITER
|
||||
from .exceptions import HelpRequested
|
||||
from .helpers import return_or_exception
|
||||
from .pool import TaskPool, SimpleTaskPool
|
||||
from ..constants import CLIENT_INFO, CMD, CMD_OK, SESSION_MSG_BYTES, STREAM_WRITER
|
||||
from ..exceptions import HelpRequested
|
||||
from ..helpers import return_or_exception
|
||||
from ..pool import TaskPool, SimpleTaskPool
|
||||
from .parser import ControlParser
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@ -131,7 +131,7 @@ class ControlSession:
|
||||
STREAM_WRITER: self._writer,
|
||||
CLIENT_INFO.TERMINAL_WIDTH: client_info[CLIENT_INFO.TERMINAL_WIDTH],
|
||||
'prog': '',
|
||||
'usage': f'%(prog)s [-h] [{CMD}] ...'
|
||||
'usage': f'[-h] [{CMD}] ...'
|
||||
}
|
||||
self._parser = ControlParser(**parser_kwargs)
|
||||
self._parser.add_subparsers(title="Commands",
|
@ -120,7 +120,7 @@ class BaseTaskPool:
|
||||
|
||||
@property
|
||||
def is_locked(self) -> bool:
|
||||
"""Returns `True` if more the pool has been locked (see below)."""
|
||||
"""Returns `True` if the pool has been locked (see below)."""
|
||||
return self._locked
|
||||
|
||||
def lock(self) -> None:
|
||||
|
0
tests/test_control/__init__.py
Normal file
0
tests/test_control/__init__.py
Normal file
@ -27,7 +27,7 @@ from pathlib import Path
|
||||
from unittest import IsolatedAsyncioTestCase, skipIf
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
from asyncio_taskpool import client
|
||||
from asyncio_taskpool.control import client
|
||||
from asyncio_taskpool.constants import CLIENT_INFO, SESSION_MSG_BYTES
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ FOO, BAR = 'foo', 'bar'
|
||||
class ControlClientTestCase(IsolatedAsyncioTestCase):
|
||||
|
||||
def setUp(self) -> None:
|
||||
self.abstract_patcher = patch('asyncio_taskpool.client.ControlClient.__abstractmethods__', set())
|
||||
self.abstract_patcher = patch('asyncio_taskpool.control.client.ControlClient.__abstractmethods__', set())
|
||||
self.print_patcher = patch.object(client, 'print')
|
||||
self.mock_abstract_methods = self.abstract_patcher.start()
|
||||
self.mock_print = self.print_patcher.start()
|
@ -24,7 +24,7 @@ from inspect import signature
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock, call, patch
|
||||
|
||||
from asyncio_taskpool import parser
|
||||
from asyncio_taskpool.control import parser
|
||||
from asyncio_taskpool.exceptions import HelpRequested
|
||||
|
||||
|
@ -26,8 +26,8 @@ from pathlib import Path
|
||||
from unittest import IsolatedAsyncioTestCase, skipIf
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
from asyncio_taskpool import server
|
||||
from asyncio_taskpool.client import ControlClient, UnixControlClient
|
||||
from asyncio_taskpool.control import server
|
||||
from asyncio_taskpool.control.client import ControlClient, UnixControlClient
|
||||
|
||||
|
||||
FOO, BAR = 'foo', 'bar'
|
||||
@ -46,7 +46,7 @@ class ControlServerTestCase(IsolatedAsyncioTestCase):
|
||||
server.log.setLevel(cls.log_lvl)
|
||||
|
||||
def setUp(self) -> None:
|
||||
self.abstract_patcher = patch('asyncio_taskpool.server.ControlServer.__abstractmethods__', set())
|
||||
self.abstract_patcher = patch('asyncio_taskpool.control.server.ControlServer.__abstractmethods__', set())
|
||||
self.mock_abstract_methods = self.abstract_patcher.start()
|
||||
self.mock_pool = MagicMock()
|
||||
self.kwargs = {FOO: 123, BAR: 456}
|
@ -24,7 +24,7 @@ from argparse import ArgumentError, Namespace
|
||||
from unittest import IsolatedAsyncioTestCase
|
||||
from unittest.mock import AsyncMock, MagicMock, patch, call
|
||||
|
||||
from asyncio_taskpool import session
|
||||
from asyncio_taskpool.control import session
|
||||
from asyncio_taskpool.constants import CLIENT_INFO, CMD, SESSION_MSG_BYTES, STREAM_WRITER
|
||||
from asyncio_taskpool.exceptions import HelpRequested
|
||||
from asyncio_taskpool.pool import SimpleTaskPool
|
||||
@ -107,7 +107,7 @@ class ControlServerTestCase(IsolatedAsyncioTestCase):
|
||||
STREAM_WRITER: self.mock_writer,
|
||||
CLIENT_INFO.TERMINAL_WIDTH: width,
|
||||
'prog': '',
|
||||
'usage': f'%(prog)s [-h] [{CMD}] ...'
|
||||
'usage': f'[-h] [{CMD}] ...'
|
||||
}
|
||||
expected_subparsers_kwargs = {
|
||||
'title': "Commands",
|
Loading…
Reference in New Issue
Block a user