1
vote
3answers
24 views

How to call a particular method in a background thread every X minutes in Python?

How to write a background thread in Python which will keep on calling a particular method every few minutes. Let's say, if I am starting my program for the first time, then it should call that ...
1
vote
1answer
23 views

Making Tornado websocket handler thread safe

I am randomly getting error 1006 ( (I failed the WebSocket connection by dropping the TCP connection) when trying to write messages from threads using Tornado's websocket server handler. I created N ...
0
votes
2answers
44 views

Qt Signals/Slots in threaded Python

I'm having troubles using PyQt4 slots/signals. I'm using PyLIRC and I'm listening for button presses on a remote. This part I have gotten to work outside of Qt. My problem comes when emitting the ...
2
votes
3answers
38 views

Thread in Python : class attribute (list) not thread-safe?

I am trying to understand Threads in Python. The code And now I have a problem, which I have surrounded in one simple class: # -*- coding: utf-8 -*- import threading class ...
0
votes
1answer
20 views

Handle a signal in another thread in Python

I have a PyGtk (GTK+ 3) application that runs in two threads: Thread A is a main app thread that executes Gtk.main() and so handles Gtk's events/signals. Thread B is a PulseAudio event thread that ...
0
votes
1answer
35 views

requests library: how to speed it up?

I am trying to send multiple requests to different web pages. At the moment I am using the "requests" library in multithreading, because I have found it most performing than urllib2. Is it possible to ...
0
votes
0answers
32 views

Threads communication in Python

I'm a python beginner and I'm creating threads for a game. My server needs to send specific information for each player and public information for all of them. I have done the first with sockets, but ...
3
votes
1answer
36 views

How does ThreadPoolExecutor().map differ from ThreadPoolExecutor().submit?

I was just very confused by some code that I wrote. I was surprised to discover that: with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor: results = list(executor.map(f, ...
0
votes
1answer
13 views

Python - Tkinter window and endless loop class at the same time [duplicate]

I've got the problem that I want to call some code after the mainloop of Python which is written in a secound class. But this Class contains a possible endless loop which will cause Tkinter to freeze ...
0
votes
1answer
33 views

How to implement 'workers' correctly

I created a simple service to allow user convert a string to upper case. def upper_service(s): return s.upper() Now, suppose I want only maximum 1000 workers to do my job (corresponding 1000 ...
1
vote
1answer
11 views

Start method on thread fails with TypeError

I receive the following error ERROR: tt.start() TypeError: 'int' object is not callable I subclassed threading.Thread to simply keep track of time and when elapsed time matches some arbitrary ...
0
votes
2answers
44 views

multithreading system calls in python

I have a python script which is something like that: def test_run(): global files_dir for f1 in os.listdir(files_dir): for f2 os.listdir(files_dir): os.system("run ...
1
vote
1answer
49 views

more complex parallel for-loop in Python

I have the following very time consuming loop, that I'd like to speed up by parallelization. for y in range(0, 288): for x in range(0, 352): ...
1
vote
2answers
30 views

Distinguishing the return values from threads when a queue is used

This is my code : queue=Queue.Queue() isbn=str(9789382711056) thread1= Thread(target = amazon, args=[isbn,queue]) thread2= Thread(target = bookadda, args=[isbn,queue]) thread3= ...
1
vote
1answer
20 views

Publisher() doesn't work in Thread

I am rewriting my program in MVC pattern, everything was okay, but now it's not. Publisher doesn't send message to the subscriber. from wx.lib.pubsub import pub from threading import Thread ...
0
votes
1answer
18 views

Python Server Socket Without Infinite Loop?

I'd like to create a class that allows sending and receiving on the same port and create an event-driven application from incoming messages while the program does it operations. I don't have much ...
-2
votes
0answers
23 views

Realtime thread creation in python

I read from this page on Thread programming with python. But, this program works when I know how many jobs I have. What if I get requests from a server to do the same thing. I will not know how many ...
0
votes
1answer
28 views

Python global variable not updating in threads

I am writing a code to use scale to update a global value VOL. The initial value of VOL can be passed to function "check_keys", however, when the scale changes its value, VOL remains unchanged in the ...
0
votes
1answer
32 views

Concurrent.futures usage guide - a simple example of using both threading and processing

I want to enable parallel processing/threading of my program using the concurrent.futures module. Unfortunately I can't seem to find any nice, simple, idiot-proof examples of using the ...
-11
votes
0answers
93 views

How to write a elegant program to send 1.5 million emails in two days [closed]

Here is my problem.I have written a java program to send emails per 40000 an hour.I used 8 thread to do the work.But the code is ugly,I look forward to rewrite the code,however,the code looks like ...
2
votes
1answer
43 views

Using Cmd module inside a Python Twisted thread

Refering to this so question, i need to run a Cmd console application that will use Python's Twisted framework for network queries, with the following example: from cmd import Cmd from ...
1
vote
2answers
23 views

Strange turtle error when threading functions

When I run a script that I made, I get a very strange error. I am threading two functions, moving(), and moveWithMouse(). The relevant code is posted here: def moving(): # Clearing the canvas and ...
0
votes
0answers
25 views

Embedding Python in Multi-Threaded c# Applications

My application provide python plugin system.In order to invoke python from c#. I have written a C wrapper of embedding python dll. You can find the gist here C wrapper gist. Then I use P/Invoke in ...
0
votes
0answers
49 views

python global value return to default after being set by thread

I am writing a python script, that change the value of global variable VOL when the scale bar changes value. the value of VOL is read by the thread with function 'check_keys' every free moments. ...
0
votes
1answer
31 views

intervals with pythons threading

I made this setInterval kind of like in javascripts only for python and it's a little different, problem is I can't seem to figure out how to cancel it since when I cancel it, it just makes a new one ...
0
votes
2answers
39 views

How to properly execute a non-blocking task with threads in Python

I 've written a small python class which extends 'threading.Thread' and sends an automatic e-mail to myself using the SMTP_SSL module. However in my calling python file it seems that things happen ...
0
votes
2answers
35 views

python multiprocess fails to start

Here is my code for a simple multiprocessing task in python from multiprocessing import Process def myfunc(num): tmp = num * num print 'squared O/P will be ', tmp return(tmp) a = [ ...
0
votes
1answer
21 views

Using Timers and Threads in Python to create assistive command line application

Let me describe my scenario: I am developing a command line-based proof-of-concept for the instructional system, and I am writing it in Python. System works on the principles of behavioral ...
2
votes
2answers
54 views

PyQt: Connecting a signal to a slot to start a background operation

I have the following code that performs a background operation (scan_value) while updating a progress bar in the ui (progress). scan_value iterates over some value in obj, emitting a signal ...
0
votes
3answers
44 views

Creating a multithreaded server using SocketServer framework in python

This question is solved. The working code is given below in this post too. Level: beginner. I am currently getting familiar with network programming with Python. I am currently working with ...
1
vote
1answer
49 views

Parsing in a thread

I have a program mainly composed of a QMainWindow. But I added some kind of "plugins", which do some particular things. One of them for example parses thepiratebay to return the latest torrents of a ...
0
votes
1answer
48 views

What is the correct way to use QThreads?

I'm trying to build an application in Python with PySide that has several windows. Each window executes some functions and the execution of one function should not stop the other windows from ...
2
votes
1answer
81 views

A confusion regarding threads in python [duplicate]

Level beginner. I have a confusion regarding the thread creation methods in python. To be specific is there any difference between the following two approaches: In first approach I am using import ...
1
vote
1answer
25 views

Subclass multiprocessing.Process but don't invoke the __init__ method of multiprocessing.Process

I know multiprocessing.Process is analogous to threading.Thread and when I subclass multiprocessing.Process to create a process, I find that I don't have to invoke the __init__() method of the parent ...
1
vote
2answers
54 views

Why does Python's GIL enforce strict ordering of processing?

from concurrent.futures import ThreadPoolExecutor, as_completed def main(): with ThreadPoolExecutor(max_workers=16) as producersPool: for i in [1,2,3,4,5,6,7,8,9,0]: ...
0
votes
0answers
22 views

How to make other server race for getting the output in Python

I have written 3 servers with threading with different Lists which include different tasks in them connected to each other and I am connecting with them with client program written like below to see ...
0
votes
0answers
22 views

How to reuse Thread in Python

I want to take noPairs and noThreads as a input from user. For example calculate shortest path between 4 pairs using only 2 threads. But in my code for every pair multiple threads are created. Instead ...
-2
votes
1answer
34 views

Python : how to have multiple threads wait on an event? [closed]

I have a python application where one thread acts like a master, it runs an algorithm once a second. I have a number of slave/peer threads, I'd like each one of them to be paused until each time the ...
0
votes
0answers
24 views

Google App Engine push tasks targeting backends not executing on production server

I have a really strange problem with the push task queue on backends on production server. I have some simple tasks which will write some log messages and a few NDB entities. When they are running on ...
0
votes
1answer
18 views

python multithreading gives type error

Here is my piece of code, as I am trying to use multithreading unipidA = ['list of data IDs with 6 characters each'] import threading; from time import ctime() def parse_data('give_data_id'): ...
3
votes
1answer
33 views

How do I get data from a subprocess PIPE while the subprocess is running in Python?

I've got a program on Windows that calls a bunch of subprocesses, and displays the results in a GUI. I'm using PyQt for the GUI, and the subprocess module to run the programs. I've got the following ...
2
votes
1answer
40 views

Why the two threading implementation behaves differently?

Why the two threading implementations in python are behaving differently ? I have two codes: 1. from threading import Thread import pdb import time def test_var_kwargs(**kwargs): time.sleep(5) ...
0
votes
2answers
33 views

Storing objects on a Process in python

I would like to store an object on a subclass of multiprocessing.Process as follows: class TestProcess( Process ): def __init__( self, foo ): super( TestProcess, self ).__init__() ...
2
votes
1answer
30 views

Python: decryption failed or bad record mac when calling from Thread

I'm getting a "decryption failed or bad record mac" error in this code-fragment: conn = psycopg2.connect(...) cursor = conn.cursor() cursor.execute("SELECT id, ip FROM schema.table;") rows = ...
1
vote
1answer
25 views

PyQt5: Got AttributeError while using QObject and QThread

I got a problem while I was developing a programme that can retrieve contains from different sites at the same time (now is basically retrieving definition of a word from two or more online ...
1
vote
0answers
35 views

Python multithreading not able to handle signal calls from modules

I am using ThreadingMixIn HTTP server told here to make a HTTP server. from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from SocketServer import ThreadingMixIn import threading class ...
2
votes
2answers
41 views

Python PySide and Progress Bar Threading

I have this code: from PySide import QtCore, QtGui import time class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(400, 133) ...
0
votes
0answers
28 views

Python unit test multi threading

I'm pretty new at unit testing using unit test module and i need to test a class which using the threading module. I didn't really find any solution on what is the best way to unit a class using ...
0
votes
0answers
22 views

Python: Using mpi4py to bcast an array to other scripts with spawn

I'm trying to write two scripts, one a master and one a worker, where the master script will spawn multiple processes of the worker and then bcast a numpy array to the worker spawns. From looking at ...
3
votes
1answer
55 views

Using Python threads to make thousands of calls to a slow API with a rate limit

I want to make thousands of calls to an API which is kind of slow -- tens of seconds to get a response. The only limit is that I can make at most one request per second. What's the best way to do ...

15 30 50 per page