Skip to content

Commit 7967b97

Browse files
committed
Rename ApplevelProtocol -> ApplevelProtocolMixin, more descriptive.
1 parent e8f0337 commit 7967b97

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

unpythonic/net/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
from .msg import MessageDecoder
3737
from .util import socketsource
38-
from .common import ApplevelProtocol
38+
from .common import ApplevelProtocolMixin
3939

4040
__all__ = ["connect"]
4141

@@ -76,7 +76,7 @@ def _handle_alarm(signum, frame):
7676
# to the beginning of the second message has already arrived and been read
7777
# from the socket, when trying to read the last batch of data belonging to
7878
# the end of the first message.
79-
class ControlClient(ApplevelProtocol):
79+
class ControlClient(ApplevelProtocolMixin):
8080
# TODO: manage the socket internally. We need to make this into a context manager,
8181
# so that __enter__ can set up the socket and __exit__ can tear it down.
8282
def __init__(self, sock):
@@ -92,7 +92,7 @@ def __init__(self, sock):
9292
self.decoder = MessageDecoder(socketsource(sock))
9393

9494
# This belongs only to the client side of the application-level protocol,
95-
# so it lives here, not in ApplevelProtocol.
95+
# so it lives here, not in ApplevelProtocolMixin.
9696
def _remote_execute(self, request):
9797
"""Send a command to the server, get the reply.
9898

unpythonic/net/common.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
from .msg import encodemsg
77

8-
__all__ = ["ApplevelProtocol"]
8+
__all__ = ["ApplevelProtocolMixin"]
99

10-
class ApplevelProtocol:
10+
class ApplevelProtocolMixin:
1111
"""Application-level communication protocol.
1212
1313
We encode the payload dictionary as JSON, then encode the text as utf-8.
@@ -21,11 +21,9 @@ class ApplevelProtocol:
2121
Transmission is synchronous; when one end is sending, the other one must be
2222
receiving. Receiving will block until success, or until the socket is closed.
2323
24-
This can be used as a common base class for server/client object pairs.
25-
It can also be used as a mixin.
24+
This is a mixin class for communication between server/client object pairs.
2625
27-
**NOTE**: The derived class (or class mixing this in) must define two
28-
attributes:
26+
**NOTE**: The class class mixing this in must define two attributes:
2927
3028
- `sock`: a TCP socket. When `_send` or `_recv` is called, the socket
3129
must be open and connected to the peer to communicate with.

unpythonic/net/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101

102102
from .util import ReuseAddrThreadingTCPServer, socketsource
103103
from .msg import MessageDecoder
104-
from .common import ApplevelProtocol
104+
from .common import ApplevelProtocolMixin
105105
from .ptyproxy import PTYSocketProxy
106106

107107
# Because "These are only defined if the interpreter is in interactive mode.",
@@ -154,7 +154,7 @@ def server_print(*values, **kwargs):
154154
print(*values, **kwargs, file=_original_stdout)
155155

156156

157-
class ControlSession(socketserver.BaseRequestHandler, ApplevelProtocol):
157+
class ControlSession(socketserver.BaseRequestHandler, ApplevelProtocolMixin):
158158
"""Entry point for connections to the control server.
159159
160160
We use a separate connection for control to avoid head-of-line blocking.

0 commit comments

Comments
 (0)