menu

Python Concurrency and Parallelism


1. Which module is used to create and manage asynchronous I/O in Python?

threading

multiprocessing

asyncio

concurrent.futures


2. Which of the following is an example of a parallel processing framework in Python?

Dask

Flask

Django

Pyramid


3. What is the GIL in Python?

A global interpreter lock that ensures only one thread can execute Python bytecode at a time.

A threading mechanism that allows Python to execute multiple threads in parallel.

A module for managing concurrent I/O in Python.

A library for creating and managing parallel processes in Python.


4. What is the purpose of the Queue class in Python threading?

To provide a way to communicate between threads.

To prevent race conditions in multithreaded code.

To ensure only one thread can access a shared resource at a time.

To provide a way to limit the number of threads that can access a resource at a time.


5. Which method is used to retrieve the result of a submitted task in Python?

result()

get()

retrieve()

fetch()


6. Which module is used to create and manage processes in Python?

threading

multiprocessing

concurrent.futures

asyncio


7. Which of the following is a disadvantage of using multiprocessing in Python?

It can be more difficult to share state between processes.

It can be less efficient than using threads.

It can be more difficult to synchronize tasks between processes.

It can be more difficult to detect and debug issues in multiprocessing code.


8. Which method is used to cancel a running task in Python?

cancel()

stop()

terminate()

kill()


9. What is Parallelism in Python?

It is the execution of multiple threads simultaneously.

It is the execution of multiple processes simultaneously.

It is the execution of a single thread in multiple ways.

None of the above.


10. Which of the following is a method of creating a new thread in Python?

Using the multiprocessing module

Using the threading module

Using the concurrent.futures module

Using the asyncio module