Logo
Pattern

Discover published sets by community

Explore tens of thousands of sets crafted by our community.

Parallel Computing with Python and multiprocessing

25

Flashcards

0/25

Still learning
StarStarStarStar

timeout argument in methods

StarStarStarStar

Many multiprocessing objects accept a 'timeout' parameter, allowing operations to wait for a specified time before giving up. Example Use: q.get(timeout=5)

StarStarStarStar

Pool class

StarStarStarStar

Offers a convenient means of parallelizing the execution of a function across multiple input values. Example Use: with multiprocessing.Pool(processes=4) as pool: results = pool.map(function, iterable)

StarStarStarStar

active_children function

StarStarStarStar

Returns a list of all live children of the current process. Example Use: children = multiprocessing.active_children()

StarStarStarStar

Condition class

StarStarStarStar

A synchronization object that allows one or more processes to wait until notified by another process. Example Use: cond = multiprocessing.Condition()

StarStarStarStar

Manager class

StarStarStarStar

Used for controlling a server process that holds Python objects and allows other processes to manipulate them. Example Use: with multiprocessing.Manager() as manager: l = manager.list()

StarStarStarStar

Barrier class

StarStarStarStar

A synchronization object for indicating that a certain number of processes have reached a particular point in their execution. Example Use: barrier = multiprocessing.Barrier(5)

StarStarStarStar

starmap method in Pool class

StarStarStarStar

Similar to map, but the elements of the iterable are expected to be iterables that are unpacked as arguments. Example Use: results = pool.starmap(function, [(arg1, arg2), (arg3, arg4)])

StarStarStarStar

multiprocessing module

StarStarStarStar

A Python module that supports spawning processes using an API similar to the threading module. Example Use: import multiprocessing as mp

StarStarStarStar

Semaphore class

StarStarStarStar

A synchronization object that implements a semaphore for limiting access to a shared resource. Example Use: sem = multiprocessing.Semaphore(2)

StarStarStarStar

Value class

StarStarStarStar

Used for creating a ctypes object in shared memory that can be accessed by different processes. Example Use: val = multiprocessing.Value('i', 0)

StarStarStarStar

SimpleQueue class

StarStarStarStar

Provides a simple FIFO queue that is especially useful for communicating between processes. Example Use: sq = multiprocessing.SimpleQueue()

StarStarStarStar

Queue class

StarStarStarStar

A queue, especially useful for processes as it is a safe way to pass messages between processes. Example Use: q = multiprocessing.Queue()

StarStarStarStar

Lock class

StarStarStarStar

A lock object that is used to synchronize processes, preventing simultaneous access to a shared resource. Example Use: lock = multiprocessing.Lock()

StarStarStarStar

Array class

StarStarStarStar

Used to create an array of ctypes in shared memory, which can be accessed by different processes. Example Use: arr = multiprocessing.Array('i', [1, 2, 3, 4])

StarStarStarStar

current_process function

StarStarStarStar

Returns the Process object corresponding to the current process. Example Use: current = multiprocessing.current_process()

StarStarStarStar

cpu_count function

StarStarStarStar

Returns the number of CPU cores that are available. Example Use: num_cores = multiprocessing.cpu_count()

StarStarStarStar

JoinableQueue class

StarStarStarStar

A Queue that additionally has join() and task_done() methods, allowing processes to wait for queue's tasks to be completed. Example Use: jq = multiprocessing.JoinableQueue()

StarStarStarStar

finalize method in Pool class

StarStarStarStar

Closes the pool and terminates its worker processes after completing all pending work. Example Use: pool.close(); pool.join();

StarStarStarStar

Event class

StarStarStarStar

A synchronization object that is used to signal between processes. Typically used to indicate a condition or a change. Example Use: event = multiprocessing.Event()

StarStarStarStar

Pipe function

StarStarStarStar

Returns a pair (conn1,conn2)(conn1, conn2) of Connection objects representing the ends of a pipe. Example Use: parent_conn, child_conn = multiprocessing.Pipe()

StarStarStarStar

RLock class

StarStarStarStar

A reentrant lock object that can be acquired multiple times, by the same process. Example Use: rlock = multiprocessing.RLock()

StarStarStarStar

initializer and initargs arguments in Pool constructor

StarStarStarStar

Used to specify an initialization function and arguments for each worker process when creating a Pool. Example Use: pool = multiprocessing.Pool(initializer=init_func, initargs=(arg1,))

StarStarStarStar

imap and imap_unordered methods in Pool class

StarStarStarStar

Variants of map method that return an iterator over the results in order (imap) or in any order as they complete (imap_unordered). Example Use: for result in pool.imap_unordered(function, iterable): process(result)

StarStarStarStar

Process class

StarStarStarStar

Represents an activity that is run in a separate process. Example Use: p = multiprocessing.Process(target=function, args=(arg1,))

StarStarStarStar

apply_async method in Pool class

StarStarStarStar

Applies a function asynchronously using arguments, returning a result object. Example Use: result = pool.apply_async(function, (arg1,))

Know
0
Still learning
Click to flip
Know
0
Logo

© Hypatia.Tech. 2024 All rights reserved.