MCPcopy Index your code
hub / github.com/PyTables/PyTables / run

Method run

examples/multiprocess_access_benchmarks.py:144–168  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

142 self.array_nbytes = array_nbytes
143
144 def run(self):
145 # create the socket, listen for a connection and use select to block
146 # until a connection is made
147 sock = socket.socket(self.socket_family, socket.SOCK_STREAM)
148 sock.bind(self.address)
149 sock.listen(1)
150 readable, _, _ = select.select([sock], [], [])
151 # accept the connection and read the sent data into a bytearray
152 connection = sock.accept()[0]
153 recv_buffer = bytearray(self.array_nbytes)
154 view = memoryview(recv_buffer)
155 bytes_recv = 0
156 while bytes_recv < self.array_nbytes:
157 bytes_recv += connection.recv_into(view[bytes_recv:])
158 # convert the bytearray into a NumPy array
159 array = np.frombuffer(recv_buffer, dtype="i8")
160 recv_timestamp = clock()
161 # perform an operation on the received array
162 array += 1
163 finish_timestamp = clock()
164 assert np.all(array == 2)
165 # send the timestamps back to the originating process
166 self.result_send.send((recv_timestamp, finish_timestamp))
167 connection.close()
168 sock.close()
169
170
171def unix_socket_address():

Callers

nothing calls this directly

Calls 1

closeMethod · 0.45

Tested by

no test coverage detected