multithreading

Making threads in a pool notice changes to global variables

Making threads in a pool notice changes to global variables Question: I’m running into an interesting circumstance with pools which I don’t fully understand. I was aware that if you edit any variable or object from a thread, changes will not be applied to the main thread and only exist in the isolated reality of …

Total answers: 1

How do i make a customtkinter button run a function without freezing

How do i make a customtkinter button run a function without freezing Question: right now am trying to make a customtkinter GUI for my code the problem that am running in which I cannot really find an answer to it is as follows, I am trying to make a button run a specific bit of …

Total answers: 1

What Actually Triggers the Asyncio Tasks?

What Actually Triggers the Asyncio Tasks? Question: Trying to understand python asyncio coming from some background on multithreading with concurrent.futures. Here is the sample script #!/usr/bin/env python3 # encoding: utf-8 """Sample script to test asyncio functionality.""" import asyncio import logging from time import sleep # noqa logging.basicConfig(format=’%(asctime)s | %(levelname)s: %(message)s’, level=logging.INFO) async def wait(i: int) …

Total answers: 1

Abstract class for thread-related class without multiple inheritance

Abstract class for thread-related class without multiple inheritance Question: I want to create an abstract class for thread-related class. Class that want to enable threading must inherit threading.Thread class, however at the same time, class that want to enable the @abstractmethod must inherit abc.ABC class. Because multiple inheritance is a bad practice, can i achieve …

Total answers: 2

How to increase asyncio thread limits in an existing co-routine

How to increase asyncio thread limits in an existing co-routine Question: I am currently working on a program using concurrency with asyncio. The code here is over simplified in order to show the problem. It is runnable without any dependencies if you need so. You have two tasks levels: 1: One in operation_loop which creates …

Total answers: 1

After thread and process close, the MainThread still running

After thread and process close, the MainThread still running Question: I’m a begineer in Python Parallel Programming, my problem is why my code still running after the thread and process close. I’m try use this two function to check which is still alive : print(f"thread : {threading.enumerate()}") print(f"process : {multiprocessing.active_children()}") and it return thread : …

Total answers: 2

Using non-multithreaded PySimpleGUI window before multithreading

Using non-multithreaded PySimpleGUI window before multithreading Question: This question could also be rephrased as: Asking if a PySimpleGUI application should enable multithreading, by using a PySimpleGUI window. This illustrates the dilema I currently have. I have two versions of the application: Regular, that does things step by step. Threaded, that processes several dataframe lines further …

Total answers: 1

Gracefully handling keyboard interrupt for Python multi-processing

Gracefully handling keyboard interrupt for Python multi-processing Question: I am working on a project which runs two separate python processes. When I do a ctrl + c to end the program, I would like the program to end gracefully. I can produce a minimum working version of the code through the following: from multiprocessing import …

Total answers: 1

Can another thread release a lock held by another thread in Python?

Can another thread release a lock held by another thread in Python? Question: I am trying to understand threading in Python via this website. Here, it has the following code for a single producer/consumer-type problem: import random SENTINEL = object() def producer(pipeline): """Pretend we’re getting a message from the network.""" for index in range(10): message …

Total answers: 1

Events for stopping Threads vs ThreadPoolExecutor

Events for stopping Threads vs ThreadPoolExecutor Question: I’m trying to understand all the differences between using a ThreadPoolExecutor and just using threads in python. I tried to use a threadpoolexecutor, and it seemed to act as a blocking function (the context didnt seem to move on and allow the main thread to continue). When I …

Total answers: 1