Skip to main content

All Questions

1 vote
1 answer
49 views

Python script locked by thread

I would like this Python 3.10 script (where the pynput code is partially based on this answer) to enter the while loop and at the same time monitor the keys pressed on the keyboard. When q is pressed, ...
BowPark's user avatar
  • 1,534
1 vote
1 answer
63 views

Is the Python ThreadPoolExecutor best used for synchronous database calls?

I need to connect to several different databases and then perform a number of queries on each one. I first tried to use asyncio until I realize that JDBC doesn't have async calls, and wrapping the ...
Bert's user avatar
  • 11
0 votes
0 answers
43 views

Unpredictable behaviour when reading from stdin in python daemon thread

The python documentation says of daemon threads: A thread can be flagged as a “daemon thread”. The significance of this flag is that the entire Python program exits when only daemon threads are left. ...
pjones123's user avatar
  • 406
0 votes
1 answer
64 views

comparative analysis of multithreading and multiprocessing

i would like to compare to each other python's multithreading and multiprocessing, here is example of multithreading : import numpy as np import threading import time ...
rain snow's user avatar
0 votes
0 answers
15 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 ...
DRags's user avatar
  • 56
0 votes
0 answers
17 views

PySimpleGUI - working of two windows at the same time [duplicate]

I have a project using the PySimpleGUI library. The application has many windows. The project is built as follows: def window_nr_2(): layout2 = [[sg.Button ('But A'), sg.Button ('But B')]] ...
Branc's user avatar
  • 1
0 votes
2 answers
213 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 ...
Eugene Yarmash's user avatar
0 votes
3 answers
38 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(&...
Stupid Hub's user avatar
1 vote
1 answer
124 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 ...
Hugo Schongin's user avatar
0 votes
1 answer
54 views

Python Multithreading: Error <var_name> already defined on variable increase

I am using Python 3.12.7. I have multiple servers that run themselves multi-threaded in a networked environment. I want to increase the variable self.msg_id in the handle_message function. Everything ...
Pascal-1609's user avatar
1 vote
1 answer
95 views

Intermittently losing ContextVar when passing from parent to child thread

I have a subclass of Thread that I use across my project. In this class, I pass in the ContextVar manually. However, at times (once or twice a day), I notice that the ContextVar in the child thread is ...
Kyuubi's user avatar
  • 1,240
0 votes
0 answers
354 views

In free-threaded Python without the GIL or other locks, can mutating an integer field on an object break the interpreter?

As of CPython 3.13, the Global Interpreter Lock can now be disabled. When running without the GIL, I'm curious about what operations are safe, where "safe" means "does not crash or ...
Zac B's user avatar
  • 4,252
0 votes
0 answers
46 views

Unable to open a new webcam connection in OpenCV from a while loop

I'm trying to make an application that can switch between webcam feeds. I put the webcam functionality into a Class, and it creates the VideoCapture object when the class is created. When I initialize ...
PBTPB's user avatar
  • 1
0 votes
0 answers
51 views

Background thread stops unexpectedly and silently when cleaning up batches in Flask app

Question: I am working on a Flask application where I need to periodically clean up stale batches in the database. To avoid unnecessary processing, I set up a background thread that checks for ...
Bilal Zafar's user avatar
-1 votes
1 answer
70 views

Python : Record 5 RTSP to 5 video files (with Thread) but get only the last frame

I'm trying to record 5 RTSP streams (from IP Cameras) to 5 video files in one python script with threading on a Windows machine. But with my code, I only have the last frame of each stream in my video ...
Jul Pandoa's user avatar

15 30 50 per page
1
2 3 4 5
102