portal 3.1.0__tar.gz → 3.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {portal-3.1.0/portal.egg-info → portal-3.1.2}/PKG-INFO +1 -1
- {portal-3.1.0 → portal-3.1.2}/portal/__init__.py +1 -1
- {portal-3.1.0 → portal-3.1.2}/portal/client_socket.py +7 -9
- {portal-3.1.0 → portal-3.1.2}/portal/contextlib.py +13 -3
- {portal-3.1.0 → portal-3.1.2}/portal/server_socket.py +5 -10
- {portal-3.1.0 → portal-3.1.2/portal.egg-info}/PKG-INFO +1 -1
- {portal-3.1.0 → portal-3.1.2}/LICENSE +0 -0
- {portal-3.1.0 → portal-3.1.2}/MANIFEST.in +0 -0
- {portal-3.1.0 → portal-3.1.2}/README.md +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal/batching.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal/buffers.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal/client.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal/packlib.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal/poollib.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal/process.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal/server.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal/sharray.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal/thread.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal/utils.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal.egg-info/SOURCES.txt +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal.egg-info/dependency_links.txt +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal.egg-info/requires.txt +0 -0
- {portal-3.1.0 → portal-3.1.2}/portal.egg-info/top_level.txt +0 -0
- {portal-3.1.0 → portal-3.1.2}/pyproject.toml +0 -0
- {portal-3.1.0 → portal-3.1.2}/requirements.txt +0 -0
- {portal-3.1.0 → portal-3.1.2}/setup.cfg +0 -0
- {portal-3.1.0 → portal-3.1.2}/setup.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/tests/test_batching.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/tests/test_client.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/tests/test_errfile.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/tests/test_pack.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/tests/test_process.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/tests/test_server.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/tests/test_socket.py +0 -0
- {portal-3.1.0 → portal-3.1.2}/tests/test_thread.py +0 -0
@@ -10,7 +10,6 @@ import time
|
|
10
10
|
from . import buffers
|
11
11
|
from . import contextlib
|
12
12
|
from . import thread
|
13
|
-
from . import utils
|
14
13
|
|
15
14
|
|
16
15
|
class Disconnected(Exception):
|
@@ -39,6 +38,7 @@ class ClientSocket:
|
|
39
38
|
if port is None:
|
40
39
|
host, port = host.rsplit(':', 1)
|
41
40
|
port = int(port)
|
41
|
+
assert host, host
|
42
42
|
self.addr = (host, port)
|
43
43
|
self.name = name
|
44
44
|
self.options = Options(**{**contextlib.context.clientkw, **kwargs})
|
@@ -186,11 +186,13 @@ class ClientSocket:
|
|
186
186
|
sock.settimeout(0)
|
187
187
|
self._log('Connection established')
|
188
188
|
return sock
|
189
|
+
except TimeoutError as e:
|
190
|
+
error = e
|
189
191
|
except ConnectionError as e:
|
190
192
|
error = e
|
191
|
-
|
192
|
-
except TimeoutError as e:
|
193
|
+
except socket.gaierror as e:
|
193
194
|
error = e
|
195
|
+
time.sleep(0.1)
|
194
196
|
if once:
|
195
197
|
self._log(f'Still trying to connect... ({error})')
|
196
198
|
once = False
|
@@ -225,9 +227,5 @@ class ClientSocket:
|
|
225
227
|
def _log(self, *args):
|
226
228
|
if not self.options.logging:
|
227
229
|
return
|
228
|
-
|
229
|
-
|
230
|
-
reset = utils.style(reset=True)
|
231
|
-
else:
|
232
|
-
style, reset = '', ''
|
233
|
-
print(style + f'[{self.name}]' + reset, *args)
|
230
|
+
contextlib.context.print(
|
231
|
+
self.name, *args, color=self.options.logging_color)
|
@@ -44,7 +44,7 @@ class Context:
|
|
44
44
|
initfns=None,
|
45
45
|
clientkw=None,
|
46
46
|
serverkw=None,
|
47
|
-
|
47
|
+
host=None,
|
48
48
|
ipv6=None,
|
49
49
|
):
|
50
50
|
|
@@ -77,8 +77,8 @@ class Context:
|
|
77
77
|
assert isinstance(serverkw, dict)
|
78
78
|
self.serverkw = serverkw
|
79
79
|
|
80
|
-
if
|
81
|
-
self.serverkw['
|
80
|
+
if host is not None:
|
81
|
+
self.serverkw['host'] = host
|
82
82
|
|
83
83
|
if ipv6 is not None:
|
84
84
|
self.clientkw['ipv6'] = ipv6
|
@@ -96,6 +96,16 @@ class Context:
|
|
96
96
|
self.initfns.append(pkl)
|
97
97
|
call_now and fn()
|
98
98
|
|
99
|
+
def print(self, name, *args, color=None):
|
100
|
+
assert args
|
101
|
+
if color:
|
102
|
+
style = utils.style(color=color)
|
103
|
+
reset = utils.style(reset=True)
|
104
|
+
else:
|
105
|
+
style, reset = '', ''
|
106
|
+
with self.printlock:
|
107
|
+
print(style + f'[{name}]' + reset, *args)
|
108
|
+
|
99
109
|
def error(self, e, name=None):
|
100
110
|
typ, tb = type(e), e.__traceback__
|
101
111
|
summary = list(traceback.format_exception_only(typ, e))[0].strip('\n')
|
@@ -7,7 +7,6 @@ import socket
|
|
7
7
|
from . import buffers
|
8
8
|
from . import contextlib
|
9
9
|
from . import thread
|
10
|
-
from . import utils
|
11
10
|
|
12
11
|
|
13
12
|
class Connection:
|
@@ -26,7 +25,7 @@ class Connection:
|
|
26
25
|
class Options:
|
27
26
|
|
28
27
|
ipv6: bool = False
|
29
|
-
|
28
|
+
host: str = ''
|
30
29
|
max_msg_size: int = 4 * 1024 ** 3
|
31
30
|
max_recv_queue: int = 4096
|
32
31
|
max_send_queue: int = 4096
|
@@ -43,10 +42,10 @@ class ServerSocket:
|
|
43
42
|
self.options = Options(**{**contextlib.context.serverkw, **kwargs})
|
44
43
|
if self.options.ipv6:
|
45
44
|
self.sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
46
|
-
self.addr = (self.options.
|
45
|
+
self.addr = (self.options.host, port, 0, 0)
|
47
46
|
else:
|
48
47
|
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
49
|
-
self.addr = (self.options.
|
48
|
+
self.addr = (self.options.host, port)
|
50
49
|
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
51
50
|
self.sock.bind(self.addr)
|
52
51
|
self.sock.setblocking(False)
|
@@ -164,9 +163,5 @@ class ServerSocket:
|
|
164
163
|
def _log(self, *args, **kwargs):
|
165
164
|
if not self.options.logging:
|
166
165
|
return
|
167
|
-
|
168
|
-
|
169
|
-
reset = utils.style(reset=True)
|
170
|
-
else:
|
171
|
-
style, reset = '', ''
|
172
|
-
print(style + f'[{self.name}]' + reset, *args)
|
166
|
+
contextlib.context.print(
|
167
|
+
self.name, *args, color=self.options.logging_color)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|