Tagged Questions
1
vote
2answers
26 views
Lambda equivalent from Python in PHP
I am trying to replicate this code in PHP:
pool = ThreadPool(num_parts)
pool.map(
lambda f: migrate(client, user_id=user_id, files=f), all_files)
What is the equivalent structure to use in ...
1
vote
2answers
35 views
how to pass argument into threading?
I want to add 5 for every element in range(1,100) with threading module,
to watch which rusult is in which thread.
I finished almost of the code,but how to pass argument into threading.Thread?
...
0
votes
2answers
31 views
retrieve data from a thread in python
I have a thread in python which handled receive OSC packets...
I need to retrieve datas from osc in my main function. How could get data from thread out of the thread ?
Here's the code to demonstrate ...
0
votes
1answer
16 views
Threading socket server in Python
I'm working on a threading server in Python but I'm running into problems with one connection blocking. When I make the first connection, it sleeps and then I don't get anything back on the second ...
0
votes
0answers
13 views
Python threading repeating timer: It works but have I done something wrong?
I am trying to create a repeating threading.Timer(). I have read this question (and some solutions) posted by others. My solution is;
import threading
from time import sleep
def timeExpired():
...
0
votes
1answer
16 views
python thread.join() not join to caller thread but to another assigned thread?
python code:
import threading
def f1():
#long looping
def f2():
#another long looping
t1 = threading.Thread(target=f1)
t2 = threading.Thread(target=f2)
t1.start()
t2.start()
...
0
votes
0answers
14 views
An async method proxy to expose all class methods in python?
I am working on a class with non-blocking self-loop "main" function by threading and may "spawn" new threading in that class self-embedded threading:
main()
|- ManagedLoopingPool()
|- ...
0
votes
1answer
54 views
Multithreading python (using _thread), doesn't do anything
First of all, here are my two python files:
sred.py:
import _thread,time
class Thread:
def __init__(self,time:int,say:str):
self.time=time
self.say=say
def create():
id = ...
0
votes
1answer
9 views
specify stream run-time (python)?
I have a twitter stream (via Twython) running. Rather than simply rely upon keyboard interrupt, I would like to disconnect() after specified time in seconds.
Being new to programming, I am unclear ...
0
votes
2answers
33 views
Lightweight Python Web Browser
Got a bit of weird request here, however it's one which I can't really figure out the answer to.
I'm writing a python application that displays web pages and locally stored images.
What I need is a ...
0
votes
2answers
38 views
Python, How to break out of multiple threads
I am following one of the examples in a book I am reading ("Violent Python"). It is to create a zip file password cracker from a dictionary. I have two questions about it. First it says to thread it ...
0
votes
0answers
17 views
how to send information from wxPython thread to a twisted thread
I have a problem that I cannot seem to solve. This problem has to do with a wxPython/twisted application that I am building. This application preforms the following functions. This application ...
0
votes
0answers
18 views
Pyserial can't read 'large' data in multiple threads
I've been trying to port a script to Windows from Linux that records data from a mic array via the serial port. The Linux version uses the termios module which isn't supported on Windows so I'm using ...
0
votes
0answers
11 views
Python: Multithreading pos_tag NLTK
def you_better_work(line):
word_pattern = re.compile('[a-zA-Z]+')
word_list = (i[0].lower() for i in pos_tag(word_pattern.findall(line)) if len(i[0]) > 1 and i[1].startswith('NN')) ...
0
votes
2answers
22 views
Multiple processes with multiple threads in Python
I've heard something about "If you want to get maximum performance from parallel application, you should create as many processes as your computer has CPUs, and in each process -- create some (how ...
2
votes
1answer
41 views
Receiving stdin input while other threads / processes are outputting
I'm asking the same question as this post, but in Python under Linux. I have a thread running in the background which output things constantly, but I would like to keep the input line at the bottom of ...
1
vote
1answer
43 views
how to safely pass a variables value between threads in python
I read on the python documentation that Queue.Queue() is a safe way of passing variables between different threads. I didn't really know that there was a safety issue with multithreading. For my ...
1
vote
2answers
32 views
Daemon thread launching software won't die
I'm trying to write a small script which will use plink.exe (from the same folder) to create a ssh tunnel (on windows).
I'm basically using os.system to launch the the command:
import time
import ...
0
votes
0answers
21 views
viewing global variable in mulitthreading
I have a gui with buttons to start a loop and another button to stop the loop. I use a global variable - run for the loop. 1 to loop and 0 to stop loop. Below is the code I am using.
import pygtk
...
0
votes
0answers
17 views
In a QGIS plugin, can't start a thread from a QDockWidget control
I have to convert a QGIS plugin (2.2.0-Valmiera 32 bits) from a QDialog to a QDockWidget. While succeeding in doing the conversion (the plugin is now docked), the threads which are launched from the ...
0
votes
1answer
35 views
tkinter issues in Python
What is best way to get this work? Script hanging at showinfo:
from tkinter import *
from tkinter.messagebox import *
from threading import Timer
def timerDone():
showinfo('Alert','Alert')
...
0
votes
3answers
62 views
How to run an infinite loop in background and stop it?
Here is my problem: Using Tkinter, I want to click a button and launch a python script.
This python script is now a module (I don't know if it s the best way to do it) imported to my main script.
This ...
2
votes
2answers
29 views
Create a tkinter window every x minutes and then automatically close it after y seconds
I'm trying to build a simple program to remind me to take breaks while using the computer. I have a reasonable understanding of python but have never played with GUI programming or threading before, ...
1
vote
2answers
37 views
Python Thread class variable is blank
I've been trying to fix this issue for the past few hours, and i just can't figure out what i'm doing wrong!
I have a single python file:
REFRESH_RATE=10.0
MAX_SECONDS=30
class user_manager:
...
0
votes
1answer
15 views
Tracking progress of joblib.Parallel execution
Is there a simple way to track the overall progress of a joblib.Parallel execution?
I have a long-running execution composed of thousands of jobs, which I want to track and record in a database. ...
1
vote
1answer
32 views
Running threading + queue in a daemon process
I have successfully implemented threading + queue in a Python file, myfile.py. Now I want this file to run as a daemon because when all the threads have completed their tasks, I want to re-populate ...
0
votes
1answer
24 views
Python multi threading with queue
Here is my code;
import threading
from Queue import Queue
words = open("words.txt")
lock = threading.Lock()
threads = 10
q = Queue(maxsize=0)
def myfunction(q):
lock.acquire()
print ...
0
votes
0answers
36 views
Open a directory dialog using python
I am trying to create a simple file dialog (preferably the system one) for use with a local server.
I can't use Tkinter because it has to be run in a sub process and the dialog box will not stay open ...
0
votes
1answer
23 views
Python multithreading raw_input
I'm currently doing some work with multithreading and i'm trying to figure out why my program isn't working as intended.
def input_watcher():
while True:
input_file = ...
0
votes
1answer
23 views
How would I handle the event of a thread finishing in python?
Say I am parsing data from a few different exchanges, I want each extra to run simultaneously so I start each one up in its own process, but inside each process I want to add output string to a list ...
0
votes
2answers
58 views
Endless recursion vs while True? [closed]
I am writing code and right now what I am going to be doing (simple version) is always have my function running gathering data and parsing it then making decisions then output those decisions to the ...
0
votes
1answer
7 views
Verify thread-safety MySQLdb (Python) prior to Trac installation
I'm trying to install Trac manually for the first time. I don't want to use a one-click-installer like Bitmani, I want to learn how to install Trac manually, so I'm following the instructions ...
0
votes
0answers
12 views
(python) Different behaviour when called using threading.Timer
I want to make a little command line music player based on the python module "mp3play".
I want to check regularly, if a song has stopped playing (and eventually start a new song), but the user should ...
0
votes
1answer
23 views
Python multiprocessing not working
I've read that you can use multiprocessing and multithreading the same way. I've tried doing this with multithreading but it is not working with multiprocessing.
I'm running the following code:
...
0
votes
1answer
22 views
Python 3.4 concurrent.futures.Executor doesn't give the control to pause and resume the threads
I am wokring with concurrent.future.ThredPoolExecutor for multi threading, i am executing few http services, i wanted the control over the threads to pause the execution when the server goes down, ...
0
votes
0answers
27 views
multiple queries with multiple threads and multiple connections
I have a very large database of 10 million rows and for that i have a single server so i have decided to split the big table of 10 million row into 4 parts and perform search (select) operation on the ...
0
votes
1answer
17 views
Wait for class variable to change using threads
I have a class that contains a boolean variable and a function that waits for the boolean to change in order to execute some code. Some (rather silly) example:
import time
class SomeClass():
def ...
1
vote
0answers
31 views
multithreaded plotting of one subplot in matplotlib
I use matplotlib with PySide and want to develop a plotting widget which can be embedded in Qt Gui.
I have to draw ~40 lines with ~100000 points each on one subplot. It can be done, but the ...
3
votes
1answer
31 views
Python : efficiency concerns in parallel async calls to fetch data from web services
I am writing a python script to fetch a list of hosts corresponding to a particular group_id. I will be using a web service call to fetch the same. The number of hosts can be in 10,000. Now for each ...
0
votes
1answer
31 views
Python threading hanging?
I have a python program that opens a socket and pulls the ssl cert. It works great but when I run it against a certain IP range the program does not proceed past thread 140. Is there a way to see ...
0
votes
1answer
39 views
Why does the worker-thread freeze while I am moving the Tkinter-GUI?
I have a Tkinter-GUI in Python 3.3 with a progress bar and a button that starts another thread. This thread fills the progress bar within 10 seconds and also prints the numbers from 0 to 99 on the ...
0
votes
2answers
30 views
Python carriage return and thread
So I have a script that will continuously read from a sensor, print a carriage return and then the sensor value. It does this until raw_input() finishes blocking (enter pressed).
However, when I run ...
0
votes
1answer
16 views
Stopping socketserver.ThreadingMixIn in python
I'm extending socketserver.ThreadingMixIn in Python 3.4 to build my own threaded server while keeping the original callbacks overwintered only for logging porpoises.
The activation and creation is ...
2
votes
1answer
30 views
Python : Passing function as parameter and multithreading
I'm new with python and I can't find why the "Without_thread" class works and not the "With_thread" class.
The purpose of my "With_thread" class is to launch a new thread when I call it with a ...
0
votes
1answer
28 views
Stop python thread that contains blocking loop
I'm trying to design object oriented interface to ZeroMQ.
I wan't to use zmq receiver in my processes but I don't want it to block the process with it's loop. So I'm trying to start loop in another ...
-1
votes
1answer
36 views
Capturing output of subprocess.Popen inside thread function
I have below code where I execute 4 commands using subprocess.Popen. I am processing log files using below code. When I process the files sequentially using below code, it works fine. Now I created ...
0
votes
2answers
19 views
How does Python multiprocessing.Process() know how many concurrent processes to open?
I'm running a script to take a list of database tables, check the row count of each table, and append the results of each query to a dictionary. I'm using multiprocessing to speed it up a bit: Manager ...
0
votes
1answer
27 views
Background thread logging to a Server Sent Event stream in a Flask app
I'm trying to build a Flask application that has some task running in the background. This task (a worker) uses standard logging module for logging what is going on. I would like to use Server Sent ...
0
votes
0answers
7 views
Sqlalchemy :session, exceptions and multithreading
I have following module structure
dbinterface.py
from sqlalchemy import....
Base = declarative_base()
#Format : ...
0
votes
0answers
30 views
How can I update a TKinter GUI live according to events occuring in a separate thread?
I have a python code with a Tkinter GUI. A separate thread read and decode inputs, while the main tread handles the GUI. The user can press various buttons in order to do calculations on the inputs, ...