4,119 questions
Advice
0
votes
6
replies
103
views
Optimizing sys.stdout.write()
I am an amateur playing around with making simple games using Python and the Windows console through sys.stdout.write(). I am aware that this method of doing 'graphics' with printing ascii characters ...
4
votes
1
answer
128
views
Python tkinter not executing button commands on Raspberry Pi
I am developing an app to select and play a mp3 clip from a list. It will be run on a Pi4 with 7” touch display and piAMP+ hat. The GUI is in tkinter with pygame for the sound plus a pair of GPIO pins ...
-1
votes
1
answer
89
views
Closing QDialog internally
I am trying to start a Dialog including QListWidget. In this list every time a status is changed, the list should get a new line. At the end, if the backup process has finished, the dialog should ...
0
votes
0
answers
50
views
OSX does not display the names of free-threaded python threads [duplicate]
I am running free-threaded python3.13t with PYTHON_GIL=0 on MacOS Sequoia 15.7.
I create threads like this:
thread = threading.Thread(target=lambda: time.sleep(10), name="test-thread")
...
-1
votes
2
answers
133
views
ThreadPoolExecutor is running the functions in sequence, not in parallel [duplicate]
We run a bunch of wireless controllers (mc's) and I want to use the controller API to transfer firmware via TFTP to each controller in preparation for an upgrade (the API call needs to be run on each ...
0
votes
1
answer
44
views
Socketio background task issues with pubsub subscription
I am running a gunicorn server with 1 eventlet worker through which I communicate with the FE via websockets.
However, I also need to listen to an external pod running some code that will emit a redis ...
-1
votes
3
answers
80
views
How to run a function while listening to a port
I am running a script that listens for webhook on my local machine using the following pattern :
from flask import Flask, request, abort
app = Flask(__name__)
@app.route("/", methods=["...
8
votes
2
answers
547
views
What happens to the asyncio event loop when multiple CPU-bound tasks run concurrently in a ThreadPoolExecutor given Python’s GIL?
I'm working on an asynchronous Python application (using FastAPI/Starlette/asyncio) that needs to offload synchronous, CPU-bound tasks to a thread pool (ThreadPoolExecutor) to avoid blocking the event ...
0
votes
3
answers
92
views
Thread tkinter does not terminate
Yet another question about tkinter terminating...
Here is a minimal code :
import threading,tkinter,random
class MiniTk :
done = lambda self : self._quit.is_set()
spot = lambda self,x,y : ...
0
votes
1
answer
82
views
Thread leakage issues during code testing
When performing OCR on user-selected regions using PaddleOCR, certain regions fail to be detected. The issue occurs in a Streamlit-based application with the following implementation characteristics:
...
0
votes
0
answers
55
views
How to exit a Python Win32 GUI program on Ctrl-C from invoking console
I have a simple Python Win32 program that works well when run under pythonw from a command prompt. When I run it under python, it keeps running in the foreground of the command prompt and can e.g. ...
0
votes
0
answers
53
views
Launch only one background task with multiple Gunicorn workers
I have a flask application that I run with Gunicorn.
The application itself would ideally be run with multiple workers. I also have some data I need to consume from Kafka, but that should only be one ...
0
votes
0
answers
21
views
Is there a way to interrupt speech in pyttsx3?
I've tried emptying the queue every time. I've tried self.engine.stop. It either doesn't affect anything or it will work and successfully interrupt the previous speech one, twice or maybe even thrice ...
-1
votes
1
answer
66
views
Background threads stoping
i have a python application, that contains functions to be called by interval.
def call_repeatedly(interval, func, *args, **kwargs):
stopped = threading.Event()
lock = threading.Lock() # Lock ...
0
votes
0
answers
413
views
How to read data from Siemens S7-1500 PLC asynchronously using Python and snap7?
I am trying to read data from a Siemens S7-1500 PLC in an asynchronous way using Python and the snap7 library. My goal is to read multiple tags concurrently. However, I am encountering the error b'CLI ...
0
votes
1
answer
85
views
PyQT manual animation of Mouse Cursor. Repeatedly change shapes needed for cursor. Works on main thread. Doesnt work on separate thread. How so?
I would like to implement changing cursor in PyQT(PySide6) application. Since didn't find animated gif support for QCursor -> decided to create my own manual animation.
So far:
When change cursor ...
0
votes
1
answer
118
views
Initializing Hugging Face Transformer restarts program loop
Initializing hugging face transformer causes loops to restart. I have created simple loop which reads text and replies but the loop is restarting new thread when initalizing chatbot pipeline. Minimum ...
0
votes
0
answers
72
views
Interface between threaded and asynchronous parts of an application in Python
I'm helping develop a Python application which collects data from several sensors and manages a server to send those data to a web application (React) to display. The application is supposed to work ...
2
votes
1
answer
130
views
Thread-insafe examples are behaving in a thread-safe way, is their a reliable way to demonstrate the problems that Locks resolve?
I am trying to create small examples using Locks to demonstrate the issues that Locks will resolve in a multi-threaded environment.
The example I created is the following,
import threading
# Shared ...
0
votes
0
answers
29
views
python3 multi threading with sqlite shared memory error in wal mode: sqlite3.OperationalError: database table is locked
I am trying to implement the shared memory database. The objective is to allow non-blocking reading access to the database for the IPC among threading.
The setting is following
def __init__(self):
...
0
votes
2
answers
489
views
How to clean up thread-local data after using ThreadPoolExecutor?
I want to use ThreadPoolExecutor to parallelize some (legacy) code with database access. I would like to avoid creating a new database connection for each thread, so I use threading.local() to keep a ...
1
vote
2
answers
43
views
Multiprocessing value() ctypes.c_wchar_p cause thread to stuck, alternative?
I'm doing concurrency using Multiprocessing() and Threading(). The idea is to spawn multiple threads from multiple process. The threads needs to access global variable that use Value() so that ...
0
votes
3
answers
50
views
How to stop 2 threads in 1 function
I have some program that communicates with the user. The program should terminate when the user has entered a sample text.
import time
import threading
def printer():
while True:
print(&...
1
vote
1
answer
181
views
Is a lock recommended in python when updating a bool in one direction in a thread, then reading it in another?
Is a lock necessary in a situation where thread 1 checks if a bool has flipped from False to True periodically within a loop, the bool being updated in thread 2?
As I understand a bool is atomic in ...
-1
votes
1
answer
39
views
pygame multiplayer jsondecodeerror
I'm developing a two-player multiplayer game with pygame.
Here is the server code and client code:
<Server Code>
import json
import pygame # Main module for the game
import pyautogui # For ...