python-multithreading refers to how to divide work into multiple streams of execution in Python.

learn more… | top users | synonyms

1
vote
0answers
15 views

Use different threading to get data and write those data to a same text file

Regarding to these data that are related to the following code, 12 41 58 82000 12 41 58 190000 12 41 58 301000 12 41 58 416000 12 41 ...
0
votes
0answers
35 views

How do I kill one specific thread, not knowing it's reference?

Let's say I have thread playing a sound every 10 seconds. I also have a settings file, containing a certain amount of thread settings (id, sound to play). My main script unpickles every thread setting,...
0
votes
0answers
24 views

function seems to malfunction when called concurrently

I am facing a very weird problem (at least I think it is weird). Basically I have a very simple function which is called from multiple threads concurrently. While calling the function from a single ...
0
votes
3answers
52 views

python: using threading , apply thread timeout

I'm using threading library in a multithreading script. I want to implement a timeout on the thread. Thus, if the thread hasn't returned task_done after a specified amount of time, it should come out ...
-1
votes
0answers
9 views

raspberry-pi and python Threading don't running

import RPi.GPIO as gpio from picamera import PiCamera import threading import time import datetime trig = 24 echo = 23 pad_pin = 24 ` class PiCCTV(object): def __init__(self): gpio....
0
votes
0answers
4 views

Saving large data file in non-blocking mode using Python

I have two multiprocessing.Processes running: first read data from a arduino board, other reads frames from a high speed camera. After N loop, I have N frames with ardunio data embedded in them; and ...
-2
votes
3answers
43 views

Can threading damage CPU?

I am new to programming and came across a Python3 tutorial on threading. It seems very useful to improve speed and efficiency. My concern would be any damage to processor if I use too many, is this ...
0
votes
0answers
10 views

Passing thread as argument in flask

I am creating a website using flask and this is my situation: I have a really big script that i need to run on the server so if I just call the script with subprocess.Popen the server will time out. ...
0
votes
0answers
30 views

How do I exit an application from a thread in python?

Let's say I run a function in a thread that prints a number every 5 seconds, while the main application is running in the background: import threading def print_num(x): x += 1 print(x) ...
0
votes
1answer
32 views

stopping a thread when another thread is done.

i am trying to run 2 threads, the first one has a function1 target, this function should read a value from a machine, and while this value =0, the output 0 is saved in an array. When this value is not ...
0
votes
1answer
14 views

why only MainThread reaches my function?

import threading in this function I want to do my coding stuff for each thread but only mainthread enters this function none of thread which has been created in main function enters this function ...
4
votes
6answers
7k views

Python Threads Hang

I have a simple threaded Python program following the standard paradigm: class SearchThread(threading.Thread): def __init__(self, search_queue): threading.Thread.__init__(self) ...
0
votes
2answers
16 views

Tkinter and threading to control continuous background process

I want to use Tkinter to interact with another thread. The output (assuming the user clicks the button after two seconds) should be: Steve Steve Joline Joline Joline Where am I going wrong? from ...
0
votes
0answers
9 views

How should i run cherrypy and another process in parallel?

I have a script that checks log files for useful lines, processes them, and then puts info in a database. I also have another one that (using CherryPy) serves a single static html file and also a ...
9
votes
4answers
19k views

The right way to limit maximum number of threads running at once?

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): import ...
0
votes
1answer
30 views

How can I change multithreading with multiprocessing in the code (Python)

I wrote a program which implements caesar-cipher with threads and queues with python. I would like to change all the threading work with multiprocessing in my code and I have no idea how to do it. I ...
0
votes
2answers
26 views

Python threading or multiprocessing for web-crawler?

I've made simple web-crawler with Python. So far everything it does it creates set of urls that should be visited, set of urls that was already visited. While parsing page it adds all the links on ...
1
vote
2answers
45 views

Python threads are not closing after join

I am using a similar code as bellow to control an rgb led strip, random values come in every few seconds and 3 threads are being created to control the 3 individual colours. import time from ast ...
0
votes
0answers
37 views

Passing kwargs through nested functions

I'm a total newcomer with python, and a bit at loss for it's specific functions (like kwargs). If all this is not understandable for human beings, i'm so sorry..english isn't my birth language. ...
0
votes
1answer
132 views

sending more than1000 requests per second in python

I am trying to send requests concurrently to a server and then record the average latency using this code: import Queue import time import threading import urllib2 data = "{"image_1":"abc/xyz.jpg"}" ...
103
votes
11answers
91k views

Timeout on a function call

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 ...
0
votes
0answers
27 views

Python global variable threading - Flask / Opencv

I want "_update_frame function" to update a global "frame" which will be the frame or video feed after the opencv manipulations in "update_frame function". This global frame can then be accessed by "...
0
votes
0answers
31 views

Cache growing infinitely large because of concurrent threads

I have a cache object designed to hold variables shared across modules. Concurrent threads are accessing & writing to that cache object using a cache handler that uses variable locking to keep ...
1
vote
2answers
53 views

Can I assume my threads are done when threading.active_count() returns 1?

Given the following class: from abc import ABCMeta, abstractmethod from time import sleep import threading from threading import active_count, Thread class ScraperPool(metaclass=ABCMeta): Queue =...
0
votes
1answer
21 views

Python threading sequence

Here is a sample program that I ran to test thread sequence for Python import threading import time import logging import random logging.basicConfig(level=logging.DEBUG, format = '%(asctime)...
0
votes
0answers
14 views

Yield from makes starting a thread not working in Python 3.5

I'm trying to use yield from in a new thread but doing that makes the new thread not to run(When I delete the yield from the thread runs). The code : def func2(): While True: ...
0
votes
1answer
7 views

Why is my Daemon thread pausing the calling function's execution?

Please forgive me if my question's terminology is not quite correct; I am not a professional programmer. This is the function my Daemon thread is calling: def _pause_console(self, pause_time): ...
0
votes
1answer
21 views

Control the run time of a python thread from outside

I am trying to spawn a python thread which perform a particular operation repeatedly based on a certain condition. If the condition doesn't met then the thread should exit. I have written the ...
0
votes
1answer
46 views

What's the correct pattern for threading in a python qt5 application?

I'm trying to write a pyqt5 application with a long running, but not CPU intensive process. I'd like to be able to run it without hanging the UI, so I'm trying to use threading, but since it doesn't ...
0
votes
0answers
10 views

Unsure of how threading.Condition works

I wanted to write a class that mimicked the std::future and std::async functionality you find in C++ in Python. Not being intimately familiar with concurrency/synchronization, I wanted to try my luck ...
0
votes
1answer
25 views

Tkinter and process in background

I have been exploring Tkinter and multithreading to no avail. I have a simple GUI in tkinter and want a function to collect data from a periphery to run when a button is pressed. Currently, I am using ...
18
votes
3answers
3k views

numpy and Global Interpreter Lock

I am about to write some computationally-intensive Python code that'll almost certainly spend most of its time inside numpy's linear algebra functions. The problem at hand is embarrassingly parallel. ...
0
votes
0answers
27 views

Python Multiclient Multithreaded server using sockets

I am trying to create a simple multi-client server architecture using socket programming on Python 3.5.2. This is my first experience with creating a server-client program. It is a Quiz program where ...
0
votes
0answers
14 views

ChildProcessError: [Errno 10] No child processes when creating a process out of another process

Here is brief summary of the problem i am facing in a client architecture to be run on 100s of machines as an application. Let's call our app 'STR' opens up a process called "Run" using multiprocess....
1
vote
1answer
33 views

How do I do multiple things at once in Python (2.7.12) (Threading?)

I'm trying to figure out how to load a long python program and make a loading animation run at the same time. I've looked around and found threading, but I haven't been able to find out how to use ...
0
votes
1answer
51 views

Global variable not changing

I have a code sort of like this, with this being simplified for your time. Basically I will have multiple threads that may start while the other is still in progress, and I want the new process to ...
-1
votes
0answers
45 views

How to avoid “too many open files” while crawling sites in PyQT4 and QTWebKit

I'm trying to use PyQt's QtWebKit to crawl a set of javascript-loaded pages, but after crawling a few my program crashes with the error: QEventDispatcherUNIXPrivate(): Unable to create thread pipe: ...
-1
votes
1answer
21 views

.locked() returns True even after release() called in python multithreading environment

I was trying to write my first code using python thread. Please see the code There is an issue when i release lock for a thread using release() as it says the lock is still availabe [locked() returns ...
0
votes
1answer
10 views

Unable to configure Gunicorn to serve a flask app running another loop concurrently

I have a simple flask app, say like this: # app.py from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello, World!' I also have a slack bot reading ...
0
votes
1answer
1k views

Raspberry Pi Model B Threading. Run 2 python scripts concurrently

I'm hoping you can help (as always). I'm making a photobooth and in short have a Python script to control the light (switches on for 30 seconds) and another to take 4 photos for the photobooth. I ...
3
votes
1answer
39 views

Why is the python thread count 2 at the beginning?

import threading print threading.activeCount() output: 2 When this code is saved into a file and run. How could it be 2 when it's the main thread? Does python run another thread by default in ...
0
votes
1answer
20 views

Update variable from imported module with Python when using Threading

In a project, I would like to separate the visualization and calculation in two different modules. The goal is to transfer the variables of the calculation-module to a main-script, in order to ...
0
votes
0answers
29 views

How to check for new messages - connection via python

I'm making a snakes&ladders game in Python 2.7. I have done all the parts of the connecting of the players, and I know when to listen/send (socket.send(),socket.recv()) to get information about ...
0
votes
1answer
20 views

Tkinter GUI stuck till end of the task when pressing a button

When I press the "start program" button, it starts a 5 second task and blocks the GUI. As i understand, I need to use Threading so each button will work independently from the GUI. I've been stuck for ...
2
votes
1answer
86 views

How to read keyboard input from a background thread in python?

I have a background thread that occasionally needs keyboard input. However, the main thread also reads input from the keyboard. When I call input() the main thread gets the input. I have tried using ...
0
votes
0answers
27 views

Python serial connection lost after sending data

I'm developing a python application using the serial module. Instead of the usual blocking implementation I use threaded implementation in this library. Besides, in fact I exchange data with Arduino ...
0
votes
1answer
31 views

Multithreading Multiple Functions Within A Class With Python's Threading Module

I have had success using Pythons Threading module for a single function within a class however I would like to expand it to multiple functions within a class. For example I have a program that parses ...
0
votes
0answers
27 views

Stopping infinitive loop in lupa in thread

I have function, which run some unknown code in LuaRuntime in thread, ex def lua(code): lua = LuaRuntime() lua.execute(code) def lua_in_thread(code): t = threading.Thread(target = lua, ...
4
votes
0answers
92 views

playing a chord in python

I want to do make a platform to play chords like guitar does. For example - to play the E chord it playes [0, 2, 2, 1, 0, 0] (from the Low-E string to the High-E string). I'm trying to play chords on ...
0
votes
0answers
16 views

Sharing multiple variables between threads in Python

I want to share multiple variables across multiple threads in Python. I know queue is considered as the best way to share a variable between threads. Following this, I will be needing a separate ...