POP Release 21.0.0ΒΆ

We are pleased to release POP 21.0.0. This release makes it possible to fork a process involving a hub.

Pseudocode example of process forking:

import pop.hub
import concurrent.futures

# Create a hub
hub = pop.hub.Hub()

# Initialize the asyncio loop structures
hub.pop.loop.create()
# Replace the default executor, ThreadPoolExecutor, with a ProcessPoolExecutor
hub.pop.loop.EXECUTOR = concurrent.futures.ProcessPoolExecutor()

# Run the function in the executor by passing it and it's args to hub.pop.loop.wrap
ret = hub.pop.loop.wrap(hub.my_sub.my_function, *my_func_args, **my_func_kwargs)
# Await the return or run_until_complete in the loop
hub.pop.Loop.run_until_complete(ret)

Functional example of process forking using a function not on the hub:

import pop.hub
import concurrent.futures
import os

hub = pop.hub.Hub()
hub.pop.loop.create()
hub.pop.loop.EXECUTOR = concurrent.futures.ProcessPoolExecutor()

# Run a function that is not on the hub in the executor.
# Here we will use os.getpid() so that we can verify that the executor is forking
ret = hub.pop.loop.wrap(os.getpid)

forked_pid = hub.pop.Loop.run_until_complete(ret)

# Get the pid of the parent process
pid = os.getpid()

# Verify that the two PIDs are different
assert forked_pid != pid