wherobots-python-dbapi 0.28.2__py3-none-any.whl → 0.30.0__py3-none-any.whl
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.
- wherobots/db/__init__.py +6 -0
- wherobots/db/_transport.py +33 -0
- wherobots/db/connection.py +823 -47
- wherobots/db/constants.py +10 -0
- wherobots/db/cursor.py +10 -0
- wherobots/db/driver.py +104 -17
- wherobots/db/errors.py +77 -0
- wherobots/db/types.py +3 -0
- {wherobots_python_dbapi-0.28.2.dist-info → wherobots_python_dbapi-0.30.0.dist-info}/METADATA +62 -1
- wherobots_python_dbapi-0.30.0.dist-info/RECORD +17 -0
- wherobots_python_dbapi-0.28.2.dist-info/RECORD +0 -17
- {wherobots_python_dbapi-0.28.2.dist-info → wherobots_python_dbapi-0.30.0.dist-info}/WHEEL +0 -0
- {wherobots_python_dbapi-0.28.2.dist-info → wherobots_python_dbapi-0.30.0.dist-info}/licenses/LICENSE +0 -0
wherobots/db/__init__.py
CHANGED
|
@@ -3,7 +3,10 @@ from .cursor import Cursor
|
|
|
3
3
|
from .driver import connect, connect_direct
|
|
4
4
|
from .errors import (
|
|
5
5
|
Error,
|
|
6
|
+
ConnectionLostError,
|
|
6
7
|
DatabaseError,
|
|
8
|
+
ExecutionCancelledError,
|
|
9
|
+
ExecutionNotFoundError,
|
|
7
10
|
InternalError,
|
|
8
11
|
InterfaceError,
|
|
9
12
|
OperationalError,
|
|
@@ -26,6 +29,9 @@ __all__ = [
|
|
|
26
29
|
"InternalError",
|
|
27
30
|
"InterfaceError",
|
|
28
31
|
"OperationalError",
|
|
32
|
+
"ConnectionLostError",
|
|
33
|
+
"ExecutionCancelledError",
|
|
34
|
+
"ExecutionNotFoundError",
|
|
29
35
|
"ProgrammingError",
|
|
30
36
|
"NotSupportedError",
|
|
31
37
|
"Region",
|
wherobots/db/_transport.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"""Transport termination independent of the WebSocket protocol's send lock."""
|
|
2
2
|
|
|
3
3
|
import errno
|
|
4
|
+
import select
|
|
5
|
+
import selectors
|
|
4
6
|
import socket
|
|
5
7
|
|
|
6
8
|
from websockets.sync.client import ClientConnection
|
|
@@ -22,3 +24,34 @@ def abort_connection(ws: ClientConnection) -> None:
|
|
|
22
24
|
finally:
|
|
23
25
|
# Even if shutdown fails, prevent any later send on this socket object.
|
|
24
26
|
ws.socket.close()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def socket_writable(ws: ClientConnection) -> bool:
|
|
30
|
+
"""Whether a small write to the transport's socket won't block right now.
|
|
31
|
+
|
|
32
|
+
For a send that must not stall the reader thread: a full send buffer
|
|
33
|
+
(a peer that keeps sending but stops reading) would park sendall(), which
|
|
34
|
+
also holds the library's protocol mutex, so even keepalive pings stall.
|
|
35
|
+
|
|
36
|
+
Never raises. Returns ``True`` (proceed, as without this check) on any
|
|
37
|
+
failure or for a transport without a real socket, such as a test fake:
|
|
38
|
+
``False`` would silently disable the caller's sends. Uses ``poll`` (or a
|
|
39
|
+
selector), not ``select.select``, which fails for fds above FD_SETSIZE.
|
|
40
|
+
"""
|
|
41
|
+
try:
|
|
42
|
+
sock = getattr(ws, "socket", None)
|
|
43
|
+
if not isinstance(sock, socket.socket):
|
|
44
|
+
return True
|
|
45
|
+
fd = sock.fileno()
|
|
46
|
+
if fd < 0:
|
|
47
|
+
return True # Closed: let the send itself report it.
|
|
48
|
+
if hasattr(select, "poll"):
|
|
49
|
+
poller = select.poll()
|
|
50
|
+
poller.register(fd, select.POLLOUT)
|
|
51
|
+
# POLLERR/POLLHUP count as writable: the send then fails fast.
|
|
52
|
+
return bool(poller.poll(0))
|
|
53
|
+
with selectors.DefaultSelector() as selector:
|
|
54
|
+
selector.register(fd, selectors.EVENT_WRITE)
|
|
55
|
+
return bool(selector.select(0))
|
|
56
|
+
except Exception:
|
|
57
|
+
return True
|