Category: Tutorials
-
Generics
In Python, generics is a mechanism with which you to define functions, classes, or methods that can operate on multiple types while maintaining type safety. With the implementation of Generics enable it is possible to write reusable code that can be used with different data types. It ensures promoting code flexibility and type correctness. Normally,…
-
URL Processing
In the world of Internet, different resources are identified by URLs (Uniform Resource Locators). Python’s standard library includes the urllib package, which has modules for working with URLs. It helps you parse URLs, fetch web content, and manage errors. This tutorial introduces urllib basics to help you start using it. Improve your skills in web scraping, fetching…
-
Socket Programming
Python Socket Programming Socket programming is a technique in which we communicate between two nodes connected in a network where the server node listens to the incoming requests from the client nodes. In Python, the socket module is used for socket programming. The socket module in the standard library included functionality required for communication between server and client at hardware…
-
Network Programming
The threading module in Python’s standard library is capable of handling multiple threads and their interaction within a single process. Communication between two processes running on the same machine is handled by Unix domain sockets, whereas for the processes running on different machines connected with TCP (Transmission control protocol), Internet domain sockets are used. Python’s…
-
Interrupting a Thread
Interrupting a thread in Python is a common requirement in multi-threaded programming, where a thread’s execution needs to be terminated under certain conditions. In a multi-threaded program, a task in a new thread, may be required to be stopped. This may be for many reasons, such as − task completion, application shutdown, or other external…
-
Thread Deadlock
A deadlock may be described as a concurrency failure mode. It is a situation in a program where one or more threads wait for a condition that never occurs. As a result, the threads are unable to progress and the program is stuck or frozen and must be terminated manually. Deadlock situation may arise in…
-
Inter-Thread Communication
Inter-Thread Communication refers to the process of enabling communication and synchronization between threads within a Python multi-threaded program. Generally, threads in Python share the same memory space within a process, which allows them to exchange data and coordinate their activities through shared variables, objects, and specialized synchronization mechanisms provided by the threading module. To facilitate inter-thread communication,…
-
Synchronizing Threads
In Python, when multiple threads are working concurrently with shared resources, it’s important to synchronize their access to maintain data integrity and program correctness. Synchronizing threads in python can be achieved using various synchronization primitives provided by the threading module, such as locks, conditions, semaphores, and barriers to control access to shared resources and coordinate the execution…
-
Daemon Threads
Daemon threads in Python are useful for running background tasks that are not critical to the program’s operation. They allow you to run tasks in the background without worrying about keeping track of them. Python provides two types of threads: non-daemon and daemon threads. By default, threads are non-daemon threads. This tutorial provides a detailed…
-
Thread Priority
In Python, currently thread priority is not directly supported by the threading module. unlike Java, Python does not support thread priorities, thread groups, or certain thread control mechanisms like destroying, stopping, suspending, resuming, or interrupting threads. Even thought Python threads are designed simple and is loosely based on Java’s threading model. This is because of Python’s Global Interpreter Lock…