MCPcopy Index your code
hub / github.com/pyscript/pyscript / test_create_named_worker_basic

Function test_create_named_worker_basic

core/tests/python/tests/test_workers.py:53–70  ·  view source on GitHub ↗

Creating a named worker dynamically should work.

()

Source from the content-addressed store, hash-verified

51
52@upytest.skip("Main thread only", skip_when=RUNNING_IN_WORKER)
53async def test_create_named_worker_basic():
54 """
55 Creating a named worker dynamically should work.
56 """
57 from pyscript import create_named_worker, workers
58
59 worker = await create_named_worker(
60 src="./worker_functions.py", name="dynamic-test-worker"
61 )
62
63 assert worker is not None
64 # Verify we can call its functions.
65 result = await worker.add(1, 2)
66 assert result == 3
67 # Verify it's also accessible via the workers proxy.
68 same_worker = await workers["dynamic-test-worker"]
69 result2 = await same_worker.add(3, 4)
70 assert result2 == 7
71
72
73@upytest.skip("Main thread only", skip_when=RUNNING_IN_WORKER)

Callers

nothing calls this directly

Calls 2

create_named_workerFunction · 0.90
addMethod · 0.45

Tested by

no test coverage detected