python-multithreading Questions

2

I Am trying to send a signal from a child thread to the main thread in a multi-threaded program (cannot use multi-processes). Unfortunately even after exhausting all the reading materials available...

2

Solved

I am attempting to automate some mouse movement to a certain position in Python 3. For this, I am using a module pyclicker, specifically the HumanClickerclass from the module. It uses an algorithm ...
Chauncey asked 31/1, 2020 at 15:7

14

Solved

How do I get a thread to return a tuple or any value of my choice back to the parent in Python?
Imparity asked 11/12, 2009 at 6:0

2

My request is to get debugging data from the debugger and pycharm prompt: Lets say I have an-old-style python synchronous program with a bug: def listdir(self, remote_path): with ssh.connect(se...

30

Solved

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

I want to call two api's at same time using python ThreadPoolExecutor (code attached). If either of these two api call responds, i want to stop calling the other. Because for my use case one of the...

6

Solved

I am using ThreadPoolExecutor class from the concurrent.futures package def some_func(arg): # does some heavy lifting # outputs some results from concurrent.futures import ThreadPoolExecutor w...
Suffolk asked 15/1, 2018 at 13:11

3

I am trying to figure out how to run my overloaded customized BaseHTTPServer instance in the background after running the "".serve_forever() method. Normally when you run the method execution wil...

1

I wanted to have a context manager where i can put some code which to be executed in a separate thread. So far i couldn't find a way to achieve what i want, best alternative is writing closures an...
Remediless asked 11/10, 2019 at 18:42

4

Solved

I have a query. I have seen examples where developers write something like the code as follows: import threading def do_something(): return true t = threading.Thread(target=do_something) t.start(...
Goodtempered asked 10/2, 2020 at 10:13

3

Solved

I know that threading.Lock() is equal to threading.Semaphore(1). Is also threading.Lock() equal to threading.BoundedSemaphore(1) ? And newly I saw threading.BoundedSemaphore(), what is the differen...

0

Here is my use-case: I am streaming some audio from a microphone using Pyaudio. I receive chunks of audio data every x milliseconds. I am opening a websockets connection if some condition is met. ...

24

I would like a clear example showing tasks being divided across multiple threads.
Salinasalinas asked 17/5, 2010 at 4:24

3

Solved

The test below passes, but I have doubts that I am using asyncio correctly: The code mixes asyncio and threading The test is passing but never exits (probably because the "loop.run_until_comp...
Amphicoelous asked 16/6, 2023 at 9:0

3

Solved

I'm new in python threading and I'm experimenting this: When I run something in threads (whenever I print outputs), it never seems to be running in parallel. Also, my functions take the same time t...
Harangue asked 10/4, 2020 at 22:51

2

Solved

I am trying to write a program which creates new threads in a loop, and doesn't wait for them to finish. As I understand it if I use .start() on the thread, my main loop should just continue, and t...
Dibble asked 11/4, 2013 at 10:9

24

Solved

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...
Overblown asked 29/1, 2009 at 17:8

2

Python's documentation for time.monotonic() states: Return the value (in fractional seconds) of a monotonic clock, i.e. a clock that cannot go backwards. The clock is not affected by system clock ...
Louanne asked 8/2, 2020 at 21:19

2

I have been studying multithreading in python for a while, however I was confused on a few issues- Firstly, are the threads created by the python threading library user level or kernel level threa...
Ilonailonka asked 19/7, 2017 at 10:32

4

I understand that __init__() is called automatically when you create a class like newThread = MyThread(property) and run() is triggered by newthread.start(). What I am looking for is something that...
Harrus asked 14/4, 2017 at 14:25

3

Solved

I am implementing a GUI in Python/Flask. The way flask is designed, the local host along with the port number has to be "manually" opened. Is there a way to automate it so that upon running the c...
Ironstone asked 17/1, 2019 at 11:52

2

Solved

I have two functions to run in parallel and each of them returns a value. I need to wait for both functions to finish and then process the returns from them. How could I achieve this in python. Ass...
Upsurge asked 17/6, 2016 at 5:3

1

I want to test a thread safety of a function using py.test My efforts: def function_to_be_tested(arg1,arg2): some functionality class Test: def setup() def teardown() def test_conc() p1=Pro...

12

Solved

I'd like to create a program that runs multiple light threads, but limits itself to a constant, predefined number of concurrent running tasks, like this (but with no risk of race condition): impor...
Mohun asked 14/10, 2013 at 21:37

4

From what I understand, the GIL makes it impossible to have threads that harness a core each individually. This is a basic question, but, what is then the point of the threading library? It seems...

© 2022 - 2024 — McMap. All rights reserved.