Tagged Questions
0
votes
0answers
19 views
Python watchdog — how should I implement this? [on hold]
I need to be able to use watchdog to watch a directory and update some sort of list (or Queue?) for files to send over the network.
The example that the watchdog API gives kind of sucks because it's ...
0
votes
1answer
14 views
How to open and close omxplayer (Python/Raspberry Pi) while playing video?
Using a Raspberry Pi and some push buttons I want to control video playback. When someone presses a button the corresponding video plays. The buttons work great. When you press a button the video ...
0
votes
0answers
8 views
Multiprocessing and Bluetooth Communication in Python
I am currently trying to develop a program which reacts on bluetooth input.
When the server receives a certain string it should execute a program while it still listens for further instructions.
I ...
0
votes
1answer
29 views
Endless loop in python class member function. Threads?
I need to implement something like this
def turnOn(self):
self.isTurnedOn = True
while self.isTurnedOn:
updateThread = threading.Thread(target=self.updateNeighborsList, args=())
...
0
votes
1answer
37 views
Stop server program inside a threading module python
I'm writing a simple information server in python that replies to 3 different commands. I must handle multiple clients using the threading module, so any other method of handling multiple clients ...
0
votes
2answers
44 views
Python: How to Encapsulate a Variable Across Multiple Classes?
I have a script using threaded timers that manipulates 2 common lists at random.
Because the class instances manipulate the lists on threaded timers, I cannot pass the variables to the classes & ...
0
votes
1answer
13 views
execute multiple threads on pyqt
I'm trying to execute two concurrent processes, the first one calculates constantly (ex. every 0.1 seconds) the frequency recorded by the microphone, while the second one gets the frequency and paint ...
0
votes
1answer
18 views
keeping track of threads accessing files, with and without Queue
I noticed some behavior when using threads and Queues that I'm having a hard time understanding. I spent a good bit of time scouring google and still haven't found an explanation that I understand, so ...
0
votes
3answers
22 views
many threads to write log file at same time python
i am writing script to retrieve WMI info from many computers at the same time then write these info in a text file:
the problem is that all threads writing on the same time
f = open("results.txt", ...
0
votes
1answer
13 views
Downloading video with python not playing while loading
I have been trying to download a video file with python and at the same time playing it with VLC.
I have tried few ways. One of them is to download in a single thread with continuous fetch and append ...
1
vote
1answer
25 views
How properly close thread in Python
I'm having trouble understanding threads in Python. I have this program:
import _thread, time
def print_loop():
num = 0
while 1:
num = num + 1
print(num)
...
0
votes
2answers
39 views
Multiprocessing Advice
I've been trying to get my head around multiprocessing. The problem is all the examples I've come across don't seem to fit my scenario. I'd like to multiprocess or thread work that involves sharing a ...
0
votes
2answers
41 views
why are my python threads blocking each other
My current predicament is that I attempted to make a blocking web serving script non blocking to allow for more than one download to take place at any one time but currently it will hang and wait for ...
0
votes
0answers
19 views
Parallel/Concurrent http request sending from urllib2 in python
I was trying to send out http post requests in parallel to a web service. To be specific, I'd like to do load test the web service under concurrent requests environment in terms of response time. So I ...
1
vote
0answers
22 views
Compare performance of Process and Thread in different implementations
I'm exploring multi-tasking in Python, after reading this article, I create an example to compare performance between multithreading and multiprocessing:
dummy_data = ''.join(['0' for i in ...
0
votes
1answer
13 views
Loading Threadable classes dynamically in Python
I have a question posted here, and I got it resolved.
My new question has to do with the code at the end that iterates through the modules in the directory and loads them dynmaically:
modules = ...
0
votes
1answer
31 views
Thread is not terminating
Can somebody tell why thread is not terminating here..
import sys, threading, select
class MyMaster(threading.Thread):
def __init__(self, event_stop):
super(MyMaster, ...
0
votes
1answer
17 views
Python 3: Parallel diagonalization of multiple matrices
I am trying to improve the performance of some code of mine, that first constructs a 4x4 matrix depending on two indices, diagonalizes this matrix and then stores the eigenvectors of each ...
1
vote
0answers
30 views
Python threadable sub-classes
I have a super class called Scrape_BASE
class Scrape_BASE(Thread):
def __init__(self):
Thread.__init__(self)
self._Text = ""
def GetText(self):
return self._Text
...
0
votes
0answers
22 views
Rabbitmq Per channel thread or per channel process while using python
Writing an python processor which will handle message from different channel. What should be good way, i.e. different process for processing different channel or different thread for processing over ...
1
vote
0answers
14 views
Multithreading in Python with ThreadPoolExecutor
I have some Python code that leverages ctypes.CDLL, according to the docs this does not involve the gil. With that being said, I am experiencing some bottlenecks that I am unclear of when profiling. ...
0
votes
1answer
69 views
Can I accelerate python file method `read()` by parallelism?
I have a lot of files(300~500) to read, and I want to accelerate this task.
The idealization is:
from multiprocessing import Pool
import os
import _io
filelist = map(open,os.listdir())
if __name__ ...
0
votes
1answer
25 views
Sending a signal from main function to a thread?
I am using Pyqt4 to make GUI in python. I want to send a signal from the main GUI to a thread in order to make a function. I know how to send a signal from thread to the main GUI but I don't know the ...
0
votes
0answers
16 views
Python Timeout connection.recv()
So I have a problem with the socket programming in python.
I'm running a multi-threaded TCP server that is supposed to handle multiple streams of connections.
There seems to be a thing where ...
0
votes
1answer
15 views
running a 2nd zmq.eventloop.ioloop
I want to create a PyZMQ eventloop in a background thread, and have it work correctly with both standalone Python scripts and IPython scripts. (IPython uses PyZMQ eventloops located in the main ...
0
votes
0answers
12 views
How do I get a value returned from a thread upon thread.join() [duplicate]
I am running this thread but don't know how do I get the value returned from the thread upon its completion.
def mymethod():
#do some data processing
return data
mt = ...
2
votes
1answer
37 views
Getting live output for executing a process, which uses multiple threads, in python?
I want to execute an executable of a Fortran code using python, with printing live output. I used subprocess.Popen to see live output as shown here. I do get live output when I execute commands like ...
0
votes
1answer
21 views
Python Multiprocessing Async Can't Terminate Process
I have an infinite loop running async but I can't terminate it. Here is a similiar version of my code :
from multiprocessing import Pool
test_pool = Pool(processes=1)
...
0
votes
1answer
13 views
Handling SIGINT (ctrl+c) in script but not interpreter?
I'm working on a project that spins off several long-running workers as processes. Child workers catch SIGINT and clean up after themselves - based on my research, this is considered a best practice, ...
0
votes
1answer
29 views
Overriding __init__ in threading.Thread
Examining this undocumented threading.Thread subclass and need a little guidance.
My understanding of what the class does is:
"""Reload module if it's been updated since last compiled."""
The ...
0
votes
1answer
30 views
Understanding DB Connection Pools in python
I'm not sure if I'm understanding the use case for DB connection pools (eg: psycopg2.pool and mysql.connector.pooling) in python. It seems to me that parallelism is usually achieved in python using a ...
0
votes
2answers
23 views
Why global var is not incremented when using threads in python?
For my code, pytest_status['finished'] variable is incrementing very interesting way. Sometimes i can see '2' or '3' (I expect corrent incrementing for every run_test function call):
test 1/53: ...
2
votes
2answers
43 views
Block execution until condition
I am using eventlet and have two main process running. One of the process acts as a producer and the other as consumer. The problem is that instead of using queue from eventlet package I want to use a ...
0
votes
1answer
27 views
Python Eclipse threaded subprocess.Popen() <terminated, exit value: 137>
I am running python 2.7 on Ubuntu in Eclipse
I am trying to call subprocess.Popen from a thread other than the main thread.
When I run this code from Eclipse:
#lsbt.py
class ...
1
vote
0answers
21 views
Pibrella + RPI Threading stop
I am writing a script that sends an email every 10 seconds once the button on the Pibrella is pressed. And I want it to stop when the button is pressed again.
So for example, the first time it is ...
1
vote
1answer
49 views
CPU usage per thread
I need to get CPU % for each process thread.
So, I create simple script:
import psutil
from psutil import Process
p = psutil.Process(4499)
treads_list = p.get_threads()
for i in treads_list:
o ...
0
votes
0answers
23 views
How to find reason of bug with limits? [duplicate]
After a some time when my Scrapy spider works on server (on my PC all good) I get an error
Traceback (most recent call last):
File ...
-1
votes
2answers
36 views
Synchronise muti-threads in Python
The class BrokenLinkTest in the code below does the following.
takes a web page url
finds all the links in the web page
get the headers of the links concurrently (this is done to check if the link ...
0
votes
1answer
14 views
Why does this http thread pool die (join), but keep functioning?
The following code takes an initial string ('a', 'b', or 'c'), and the two thread types pass it back and forth, appending 'W' and 'H' to it repeatedly, marking that the Worker thread or the Http ...
0
votes
1answer
27 views
Want to decorate email sending with new thread
I am stuck on decorating the function.
Help me find out the problem.
Decorator:
def sync(f):
def wrapper(*args, **kwargs):
thr = Thread(target=f, args=args, kwargs=kwargs)
...
0
votes
0answers
7 views
Is a PyMySQL connection causing my heap to overflow?
I have a class for connecting to a mysql db, and one thread repeatedly makes calls to the db (select, insert, update) (it makes many calls). My heap is overflowing, I presume because of a memory leak, ...
0
votes
1answer
15 views
return values with thread.start() in python (using queue)
I'd like to create a multi-threaded version of a function. I discover t.start() returns None, so I have to use queue.
I searched the documentation, but I don't understand how to use it in my example.
...
2
votes
1answer
43 views
Twisted execute 10 threads in same time and wait for result
Writing a program that verify list of emails syntax and MX records, as blocking programming is time consuming, I want do this async or by threads, this my code:
with open(file_path) as f:
# check ...
-2
votes
1answer
55 views
Python: is there any sense to use both multiprocessing and threading (for the same task)? [closed]
If I have an app or function (which can't be split in parts) that works faster multithreaded and also works faster when using multiprocessing, how to start multiple threads in each process?
edit:
I ...
0
votes
1answer
31 views
How can I limit API calls in multithreaded program in Python 3?
After much research, I'm not sure what the best practice is, is my following idea decent?
I want to access an API that limits the total number of calls I can make to 50 per minute.
My program has ...
1
vote
0answers
39 views
How to make just “a part”of the code waiting in python
It's the first time I try to use python, so I am a newbie in this field. I got at my University a project where I have to implement an AI using The AI Sandbox framework. The game I am talking about is ...
0
votes
1answer
21 views
Segmentation fault in a python with queue and mutithreading
I'm having Segmentation fault in a python program and can't figure out what is causing it:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffebfff700 (LWP 13584)]
...
1
vote
1answer
31 views
Python multithreading + multiprocessing BrokenPipeError (subprocess not exiting?)
I am getting BrokenPipeError when threads which employ multiprocessing.JoinableQueue spawn processes. It seems that happens after the program finished working and tries to exit, because it does ...
0
votes
2answers
42 views
AttributeError: 'Thread1' object has no attribute '_initialized'
well i got this problem when trying to stop a thread with the .join method
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
t1.alto()
File "C:\Program ...
0
votes
1answer
50 views
How do I use Python multiprocessing to get rid of nested while loops
I made this ray tracer to simulate two lens. Each time a ray hits a screen, the position on that screen is voted for. However, this is running so slowly. It's nothing with the ray tracer, is just the ...