1
vote
0answers
24 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
16 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
24 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
1answer
27 views

AttributeError: 'Thread1' object has no attribute '_initialized'

well i got this problem when trying to stop a thread with the .join method TRACEBACK Traceback (most recent call last): File "<pyshell#16>", line 1, in <module> t1.alto() File ...
0
votes
1answer
37 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 ...
1
vote
3answers
34 views

An easily refreshable Queue for Python Threading

I would like to find a mechanism to easily report the progress of a Python thread. For example, if my thread had a counter, I would like to know the value of the counter once in awhile, but, ...
1
vote
1answer
15 views

Python Threading.Timer is calling command without waiting

I have a very basic Tkinter application that I'm trying to set to automatically refresh. I am using threading.Timer to trigger a function called go at the end of which cocalls the timer to reset it ...
0
votes
3answers
24 views

Python threading timer

I have the following script in python that calls a function every X seconds creating a new thread: def function(): threading.Timer(X, function).start() do_something function() My question ...
-2
votes
0answers
25 views

Killing a thread in Python [duplicate]

So im creating a thread for every person in a list, each thread will have the persons Ip,Username,Password. I got it all working good UNLESS the Ip does not exist or the box is not on. the thread is ...
0
votes
1answer
14 views

GObject.idle_add(), thread.join() and my program hangs

I've a problem: my main thread should start and join a thread that has a to run about 10-15 seconds. So: my main thread starts a child thread, whom has to run about 10-15 seconds my main thread ...
-2
votes
0answers
25 views

'NoneType' object has no attribute 'update'

I've got this bit of Python that is giving me some major headaches, hopefully someone can help me out. import Queue import threading import subprocess as subp from pymongo import MongoClient import ...
3
votes
1answer
59 views

Best (pythonic) way to interrupt and cancel a function call in progress?

I want a function foo() to do a number of things in one thread, with waiting periods during which it periodically checks if another thread (the main script) has set a please_stop variable to True, in ...
1
vote
1answer
14 views

multiprocessinq.Queue as attribute of Queue.Queue child

I'm trying to figure out what the following module is doing. import Queue import multiprocessing import threading class BufferedReadQueue(Queue.Queue): def __init__(self, lim=None): ...
1
vote
1answer
25 views

Python Process Multiple Files

As an example, let's say we have 3 CSV files with millions of lines per file: file_1.csv contains 10 million lines file_2.csv contains 2.5 million lines file_3.csv contains 7.1 million lines I ...
0
votes
1answer
19 views

Get the thread state stated from another class

Let's say I have the following code (start.py) that starts a thread and never exits (Note: don't mind the typos or lack of some code lines, just get the idea.): from threading import Thread from ...
0
votes
1answer
20 views

What is the best option to thread in a spider?

I wrote a spidering script in Python that works just fine. However, it takes a very long time to finish (upwards of 9 hours, depending on how many links the site has). I want to implement threading ...
0
votes
0answers
33 views

How to insert big array to the mysql with python?

I have around 5000000 strings in array and I need to write each as a row to the mysql db, as fast as I can. Now I'm using multiprocessing: def my_api_off(api): print api db = ...
0
votes
0answers
15 views

How to pygame.midi.quit() from a separate thread?

I have some code which runs a thread. In the thread I run a test which sends some MIDI messages. I have another thread which handles my MIDI in. At the end of the thread I want to ...
0
votes
2answers
43 views

try-except-finally code not working as expected in threaded application

Execution abruptly halting if the thread / process is killed makes sense Why it won't execute cleanup code when I exit the main program normally by clicking the [X] on my terminal window? I'm ...
2
votes
0answers
22 views

Python2 : How to speed up Queue.get with timeout?

I'm trying to write a fast event system for multiples threads using Queues. Each Thread has a stdin and wait for this one to be filled. So main part of my thread is like that : class ...
1
vote
1answer
33 views

What happens with a thread if it's in a infinite while loop python

I found this article about queue's in python: http://www.blog.pythonlibrary.org/2012/08/01/python-concurrency-an-example-of-a-queue/ It works fine but I have question about it. In the run method of ...
1
vote
3answers
40 views

Why do I see extra line breaks when working with python multiprocessing pool?

Example: from multiprocessing.dummy import Pool as ThreadPool def testfunc(string): print string def main(): strings = ['one', 'two', 'three', ...] pool = ThreadPool(10) results = ...
0
votes
2answers
18 views

Using threads with python pyqt?

I am trying to make a GUI in python using pyqt4 which incorporates a waterfall sink which is connected with an USRP. The problem is that the data should be shown in waterfall sink continuously which ...
1
vote
1answer
26 views

Having multiple processes/threads running at all times, accessing a sqlite3 db until a condition is met

Bear with me - this is my first mulit-threading/processing python project. I'm working on a python script which is supposed to run n instances of some.exe where each requires an ID as a parameter. ...
0
votes
0answers
16 views

Using multiple thread to write on different sheets of workbook in python

wb = xlrd.open_workbook('New.xlsx') wb1 = xlsxwriter.Workbook('Old.xlsx') def thread_1(): print('Startind thread 1') s1=wb.sheet_by_index(0) sh1=wb1.add_worksheet('Base') for i in ...
1
vote
2answers
21 views

Flask and/or Tornado - handling time consuming call to external webservice

I've got a flask app that connects with given URL to external services (with different, but usually long response times) and searches for some stuff there. After that there's some CPU heavy operations ...
0
votes
0answers
15 views

dynamically making threads in python for each user read in from text file

So i have made a program that updates peoples boxs automatically, i had it all working then i went back and made it multithreaded, Everything works when i hard code the threads in my self, now i want ...
0
votes
0answers
10 views

boost::python, python ipython and std::thread

I (again) need your help: my software uses boost::python to create a custom extension to python in C++, generating a .so (shared object) that can be imported in Python such that new classes are ...
1
vote
2answers
40 views

Synchronizing 2 threads in python

I am having great difficulty in synchronising 2 Threads. Each thread depends on the results of the other thread. Let's say I have the following code: from multiprocessing import Condition, Process ...
0
votes
2answers
30 views

Socket server not responding when in thread

I'm trying to set up a simple socket server in a qgis plugin. The ultimate goal is to communicate between qgis and matlab. I found a clear example for something comparable from here: ...
3
votes
2answers
26 views

Looking into getting into Python specifically for a project that involves threads and graphs

I am well experienced in the C languages, but for a project that I have been assigned in one of my classes, I am considering using it as a project to introduce me into Python. I have never used Python ...
-4
votes
0answers
33 views

multithread recursive function in python

I need to rewrite a recursive function in a multithread version. SINGLE THREAD: def derivative(lst, var): # Example of lst = [1 + [3 * x]] if len(lst) == 1: return ...
1
vote
1answer
25 views

How to obtain the results from a pool of threads in python?

I have searched here about how to do threading in python, but by far i haven't been able to get the answer i need. I'm not very familiar with the Queue and Threading python classes and for that reason ...
1
vote
1answer
49 views

Avoid calling an object after it is dead

I have a threading.Thread subclass in python and its run method is as follows: def run(self): while self.caller.isAlive(): details = self.somefile.read() if self.status() and ...
0
votes
1answer
33 views

Python, thread-function doesn't execute and the object disappears

We are trying to run this code in Python, but while the function print_time works, the TestReactionTime doesn't execute (it doesn't even print). The calls to both functions are identical. Also, and ...
0
votes
1answer
18 views

PySide threading: Fast enough for realtime MIDI I/O, for music? [closed]

I want to use PySide's QThread to write a program with a MIDI I/O thread. I have heard that Python is too slow for math at the audio sample rate (44 thousand updates per second), but I do not need ...
1
vote
1answer
35 views

How can i create own logging instance for each thread?

For example, i have this files with classes that i want use (only example, maybe not working) # helper_one.py import logging logger = logging.getLogger('HelperOne') class HelperOne: def ...
1
vote
1answer
31 views

keeping console control in tkinter using threading

I'm trying to set up a tkinter window that I can interact with outside of the main loop, using a queue. When I interpret this in spyder, it works fine. after launch()-ing, my Tk window appears, and I ...
1
vote
1answer
14 views

Python Requests URLLib3 Connection Pool Size

In my application, I am sending off several request.post() requests in threads. Depending on the amount of data I have to post, the number of threads created can be in their hundreds. The actual ...
0
votes
0answers
8 views

How to use threading with pyjack?

I'm trying to use the pyjack library to play a sound using JACK in linux. I want to do this in a separate thread so other things can continue to run in the meantime, but playing something in JACK ...
0
votes
1answer
33 views

Python Tkinter: Progress bar does not get minimized when main application gets minimized

Please run the following example. I have created a progress bar for my application, and by pressing the "Open" button a progress bar pops up. However, the progress bar does not get minimized when ...
1
vote
2answers
16 views

Kill all Pool workers in python multiprocess

I want to stop all threads from a single worker. I have a thread pool with 10 workers: def myfunction(i): print(i) if (i == 20): sys.exit() p = multiprocessing.Pool(10, ...
0
votes
0answers
18 views

Python multi-thread multi-interpreter C API

I'm playing around with the C API for Python, but it is quite difficult to understand some corner cases. I could test it, but it seems a bug-prone and time consuming. So I come here to see if somebody ...
1
vote
2answers
78 views
+50

Using MySQL table as a queue with threads in Python

I have a DB with a queue table, new entries are inserted continuously in the queue. I want a Python script to execute the queue as fast as possible, and I think I need some threaded code to do so, ...
0
votes
1answer
28 views

Python Tkinter: Progress bar malfunction when using multi-threading

Please run the following example. I have created a progress bar for my application, and by pressing the "Open" button a progress bar pops up. However, the progress bar does not fill up and it appears ...
0
votes
1answer
10 views

Breaking threading.Timer when a function is executed

I set a timer in Python for, lets say, 20 seconds, but in between if another function is called, then the timer should break. Is there any way to execute this using Python's threading.Timer?
1
vote
1answer
22 views

unexpected indent outputs of print function with multithreads in python

I have been trying to write a keyboard listener without installing any packages. What I wanted was to create a non-blocking way of reading only one character of user input. So I created another thread ...
1
vote
0answers
18 views

Unexpected parallelism behavious with threading in python 2.7 on Ubuntu [duplicate]

I am running this very simple example on Ubuntu using python 2.7. #!/usr/bin/python import threading threads = [] def incrementCounter(tid): print("Thread " + str(tid) + " is starting") ...
0
votes
1answer
29 views

Python Threading - Prioritising Input Over Output

I have a python program that sends a message over a network using sockets, which uses two threads, one to run the server, and one to run the client. However, if a message is received while the user ...
0
votes
0answers
29 views

New thread for every element read in from text file in python

Ok so i have a program that is fully functional but i would like to multi-threaded it to make it faster, what it does is updates a box. Right now it does one box at a time i would like to do all at ...