MCPcopy Create free account
hub / github.com/PyTables/PyTables / test_multiprocess

Method test_multiprocess

tables/tests/test_basics.py:2274–2321  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2272@common.unittest.skipIf(not common.blosc_avail, "Blosc not available")
2273class BloscSubprocess(common.PyTablesTestCase):
2274 def test_multiprocess(self):
2275 # Create a relatively large table with Blosc level 9 (large blocks)
2276 h5fname = tempfile.mktemp(prefix="multiproc-blosc9-", suffix=".h5")
2277 try:
2278 size = 300_000
2279 sa = np.fromiter(
2280 ((i, i**2, i // 3) for i in range(size)), "i4,i8,f8"
2281 )
2282 with tb.open_file(h5fname, "w") as h5file:
2283 h5file.create_table(
2284 h5file.root,
2285 "table",
2286 sa,
2287 filters=tb.Filters(complevel=9, complib="blosc"),
2288 chunkshape=(size // 3,),
2289 )
2290
2291 if common.verbose:
2292 print("**** Running from main process:")
2293 _worker(h5fname)
2294
2295 if common.verbose:
2296 print("**** Running from subprocess:")
2297
2298 try:
2299 qout = mp.Queue()
2300 except OSError:
2301 print("Permission denied due to /dev/shm settings")
2302 else:
2303 ps = mp.Process(
2304 target=_worker,
2305 args=(
2306 h5fname,
2307 qout,
2308 ),
2309 )
2310 ps.daemon = True
2311 ps.start()
2312
2313 result = qout.get()
2314 if common.verbose:
2315 print(result)
2316
2317 ps.join()
2318 # Avoid warnings with later tests forking subprocesses.
2319 ps.terminate()
2320 finally:
2321 Path(h5fname).unlink()
2322
2323
2324class HDF5ErrorHandling(common.PyTablesTestCase):

Callers

nothing calls this directly

Calls 3

_workerFunction · 0.85
create_tableMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected