Client64¤
Base class for communicating with a 32-bit library from 64-bit Python.
Server32 is used in combination with Client64 to communicate with a 32-bit library from 64-bit Python.
Client64 ¤
Client64(
module32,
*,
add_dll_directory=None,
append_environ_path=None,
append_sys_path=None,
host="127.0.0.1",
port=0,
protocol=5,
rpc_timeout=None,
server32_dir=None,
timeout=10,
**kwargs,
)
Base class for communicating with a 32-bit library from 64-bit Python.
Starts a 32-bit server, Server32, to host a Python class that is a wrapper around a 32-bit library. Client64 runs within a 64-bit Python interpreter and it sends requests to the server which calls the 32-bit library to execute the request. The server then sends the response back to the client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module32
|
PathLike
|
The name of, or the path to, a Python module that will be imported by the 32-bit server. The module must contain a class that inherits from Server32. |
required |
add_dll_directory
|
PathLike | Iterable[PathLike] | None
|
Add path(s) to the 32-bit server's DLL search path. See os.add_dll_directory for more details. Supported on Windows only. Added in version 1.0 |
None
|
append_environ_path
|
PathLike | Iterable[PathLike] | None
|
Append path(s) to the 32-bit server's
os.environ["PATH"] variable. This may be useful if
the library that is being loaded requires additional libraries that
must be available on |
None
|
append_sys_path
|
PathLike | Iterable[PathLike] | None
|
None
|
|
host
|
str | None
|
The hostname (IP address) of the 32-bit server. If Changed in version 1.0 A value of |
'127.0.0.1'
|
port
|
int
|
The port to open on the 32-bit server. If |
0
|
protocol
|
int
|
The pickle protocol to use. Added in version 0.8 |
5
|
rpc_timeout
|
float | None
|
The maximum number of seconds to wait for a response from the 32-bit server.
The RPC
timeout value is used for all requests from the server. If you want different
requests to have different timeout values, you will need to implement custom
timeout handling for each method on the server. Default is Added in version 0.6 |
None
|
server32_dir
|
PathLike | None
|
The directory where the 32-bit server is located. Specifying this value may be useful if you created a custom server. Added in version 0.10 |
None
|
timeout
|
float
|
The maximum number of seconds to wait to establish a connection with the 32-bit server. |
10
|
kwargs
|
Any
|
{}
|
Raises:
Type | Description |
---|---|
OSError
|
If the 32-bit server cannot be found. |
ConnectionTimeoutError
|
If the connection to the 32-bit server cannot be established. |
Note
If module32
is not located in the current working directory then you
must either specify the full path to module32
or you can
specify the folder where module32
is located by passing a value to the
append_sys_path
parameter. Using the append_sys_path
option also allows
for any other modules that module32
may depend on to also be included
in sys.path so that those modules can be imported when module32
is imported.
Source code in src/msl/loadlib/client64.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
connection
property
¤
connection
HTTPConnection | None
— The connection to the 32-bit server.
The value is None
for a mocked connection or if the connection has been closed.
host
property
¤
host
port
property
¤
port
request32 ¤
request32(name, *args, **kwargs)
Send a request to the 32-bit server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of a method, property or attribute of the Server32 subclass. |
required |
args
|
Any
|
The arguments that the method of the Server32 subclass requires. |
()
|
kwargs
|
Any
|
The keyword arguments that the method of the Server32 subclass requires. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
Whatever is returned by calling |
Raises:
Type | Description |
---|---|
Server32Error
|
If there was an error processing the request on the 32-bit server. |
ResponseTimeoutError
|
If a timeout occurs while waiting for the response from the 32-bit server. |
Source code in src/msl/loadlib/client64.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
shutdown_server32 ¤
shutdown_server32(kill_timeout=10)
Shut down the 32-bit server.
This method shuts down the 32-bit server, closes the client connection, and deletes the temporary file that was used to store the serialized pickled data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kill_timeout
|
float
|
If the 32-bit server is still running after Added in version 0.6 |
10
|
Returns:
Type | Description |
---|---|
tuple[IO[bytes], IO[bytes]]
|
The Limit the total number of characters that are written to either Changed in version 0.8 Prior to version 0.8 this method returned |
Tip
This method gets called automatically when the reference count to the
Client64 instance reaches zero (see object.__del__
).
Source code in src/msl/loadlib/client64.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|