python-multithreading Questions

16

Solved

I want to fire off a function every 0.5 seconds and be able to start and stop and reset the timer. I'm not too knowledgeable of how Python threads work and am having difficulties with the python ti...
Manolo asked 15/9, 2012 at 6:49

0

I'm using FastAPI with non-async endpoints running over gunicorn with multiple workers, from the uvicorn.workers.UvicornWorker class as suggested here. Latley, I noticed high latency in some of our...
Plaster asked 5/12, 2022 at 8:39

6

I've started programming in Python a few weeks ago and was trying to use Semaphores to synchronize two simple threads, for learning purposes. Here is what I've got: import threading sem = threading...
Capriola asked 20/7, 2015 at 3:48

1

I'm using multiple interpreters with multiple threads, and I'm trying to use PyThreadState_SetAsyncExc to stop a script, but it has no effect: void stop() { PyThreadState *ts = PyThreadState_Swap...
Davedaveda asked 9/12, 2019 at 13:11

12

Solved

I was studying the python threading and came across join(). The author told that if thread is in daemon mode then i need to use join() so that thread can finish itself before main thread terminates...
Lemaceon asked 26/2, 2013 at 9:21

4

I'm trying to make threaded flight software for a project in Python 3.4, in which I need threads to restart themselves in case an I/O error occurs during a sensor read or another fluke crash like t...
Stromberg asked 17/4, 2015 at 6:53

9

Solved

In the Python documentation it says: 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. The ...
Volding asked 10/10, 2008 at 3:24

5

Solved

I use the following code to handle the SIGINT event. The code sets a multiprocessing.event to "wakeup" the main thread which is waiting. import multiprocessing import signal class Class1(object):...
Curmudgeon asked 26/6, 2014 at 3:59

1

Solved

I use FastAPI for a production application that uses asyncio almost entirely except when hitting the database. The database still relies on synchronous SQLAlchemy as the async version was still in ...
Aerolite asked 1/8, 2022 at 14:34

2

Solved

An Exception is raised in threading._wait_for_tstate_lock when I transfere hugh data between a Process and a Thread via multiprocessing.Queue. My minimal working example looks a bit complex first -...

2

I have a question for pytest I would like to run same pytest script with multiple threads. But,i am not sure how to create and run thread which is passing more than one param. (And running thread ...

31

Solved

Is it possible to terminate a running thread without setting/checking any flags/semaphores/etc.?
Lorenzalorenzana asked 27/11, 2008 at 14:55

4

I want to use XGBoost for online production purposes (Python 2.7 XGBoost API). In order to be able to do that I want to control and limit the number of threads used by XGBoost at the predict operat...
Albuminuria asked 15/1, 2018 at 19:6

2

Solved

I have a Flask application that works fine when run on the commandline, but when it is run through uWSGI it doesn't respond correctly to requests or the worker thread doesn't work properly. I've re...
Dimitris asked 20/8, 2018 at 12:56

4

I need a timed input for python 3 on both Mac and Windows which, if the user runs out of time, automatically chooses one of the options. Every other answer for a question I've seen only terminates ...

2

Solved

How can I check if the Main Thread is alive from another ( non-daemon, child ) thread? The child thread is a non-daemon thread and I'd like to check if the Main thread is still running or not, and...
Mountfort asked 3/5, 2014 at 9:34

3

Solved

I'm designing an application in Python which should access a machine to perform some (lengthy) tasks. The asyncio module seems to be a good choice for everything that is network-related, but now I ...
Atwitter asked 7/10, 2015 at 18:51

3

I am quite new to Python. I am trying my hands on threading module. I came across Event objects. Event objects has wait set clear functions. I understand what wait, set and clear are doing. But I...
Keelboat asked 24/9, 2019 at 21:43

3

I want to run a service that requests urls using coroutines and multithread. However I cannot pass coroutines to the workers in the executor. See the code below for a minimal example of this issue:...

1

I acquire samples (integers) at a very high rate (several kilo samples per seconds) in a thread and put() them in a threading.Queue. The main thread get()s the samples one by one into a list of len...
Aurita asked 20/9, 2016 at 15:49

3

In Python 2 there is a function thread.interrupt_main(), which raises a KeyboardInterrupt exception in the main thread when called from a subthread. This is also available through _thread.interrup...

2

Code to add and delete values in a list are operations performed in different threads. using these global variables in multi-threading: from threading import Thread import time a=[] i = 0 j = 0 ...
Intrusion asked 21/5, 2015 at 9:43

1

Solved

just a small problem. I'm using around 6 threads, all of which are printing something every couple of seconds. Occasionally they print on the same line like this: OUTPUT OUTPUT OUTPUTOUTPUT OUTPUT...
Creamy asked 17/12, 2021 at 17:0

1

Solved

For some, simple thread related code, i.e: import threading a = 0 threads = [] def x(): global a for i in range(1_000_000): a += 1 for _ in range(10): thread = threading.Thread(target=x) ...

3

Solved

I have the following code, which has been simplified: import concurrent.futures pool = concurrent.futures.ThreadPoolExecutor(8) def _exec(x): return x + x myfuturelist = pool.map(_exec,[x for ...
Crusado asked 31/1, 2018 at 0:1

© 2022 - 2025 — McMap. All rights reserved.