4,119 questions
Advice
0
votes
6
replies
104
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
146
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 ...
1522
votes
25
answers
1.2m
views
How do I use threading in Python?
I would like a clear example showing tasks being divided across multiple threads.
3
votes
1
answer
311
views
Python 3.14 removes GIL. What possibilities of data races can happen in Python now? And how to handle them? [closed]
Are python references atomic under concurrent access? Are dictionaries and lists thread-safe?
0
votes
2
answers
87
views
threading.Thread cannot catch a PyCharm "stop" button termination event
I am using Pycharm. When I click the "stop" button, the subprocess.Popen deletes the left over .bat files. But after putting the subprocess.Popen inside a threading.Thread function, the .bat ...
-1
votes
1
answer
92
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 ...
1029
votes
31
answers
1.4m
views
Is there any way to kill a Thread?
Is it possible to terminate a running thread without setting/checking any flags/semaphores/etc.?
2
votes
1
answer
68
views
Cannot start a ThreadPoolExecutor inside a threading.Thread function
In this example, Tkinter GUI starts ThreadPoolExecutor. But ThreadPoolExecutor is inside a threading.Thread function. The thread function says it's finished
before ThreadPoolExecutor has started ... ...
680
votes
30
answers
792k
views
How to get the return value from a thread?
The function foo below returns a string 'foo'. How can I get the value 'foo' which is returned from the thread's target?
from threading import Thread
def foo(bar):
print('hello {}'.format(bar))
...
2
votes
1
answer
2k
views
import sentence_transformers hangs on macOS with [mutex.cc] RAW: Lock blocking error
I'm encountering a persistent issue where importing the sentence_transformers library on macOS causes my Python script to hang indefinitely. When the script hangs, the only output I see is a low-level ...
2
votes
1
answer
132
views
Threading or asyncio for serial communications?
I'm running some serial commands to test connected devices under test (DUTs), & we have a need to run these in parallel/concurrently to speed up our tests. I would like some feedback on which ...
0
votes
0
answers
51
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
135
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 ...
552
votes
24
answers
734k
views
Timeout on a function call
I'm calling a function in Python which I know may stall and force me to restart the script.
How do I call the function or what do I wrap it in so that if it takes longer than 5 seconds the script ...
8
votes
2
answers
565
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 ...