3
votes
0answers
37 views

Python: Is it safe to get value from the same list iterator in multiple threads?

I know that generators are not thread safe. When accessed by two threads at the same time, an error occurs: ValueError: generator already executing But iterators are different from generators, ...
2
votes
0answers
16 views

lack of speedup and erroneous results with OpenMP and Cython

I'm trying to speed up a simple piece of code written in Cython with OpenMP. It's a double loop that for each position in the input array adds a quantity at each reference point. Here's the main part ...
1
vote
1answer
15 views

pyqt QThread blocking main thread

I'm trying to create a simple threaded application whereby i have a method which does some long processing and a widget that displays a loading bar and cancel button. My problem is that no matter how ...
0
votes
1answer
15 views

What's the advantage of running multiple threads per UWSGI process?

If I'm performing blocking operations like querying a database, then what is the advantage? How does this add extra worthwhile capacity?
0
votes
1answer
26 views

Python Multiprocessing list-dictionary comparison

I have a list contains 700,000 items and a dictionary contains 300,000 keys. Some of the 300k keys are contained within the 700k items stored in the list. Now, I have built a simple comparison and ...
-1
votes
1answer
51 views

python : print output of each thread to seperate file no processes [on hold]

I have several threads and each thread writes output to stdout. However I want to redirect the ouput of each thread to a separate file independently of each other, then merge them to keep he flow of ...
1
vote
1answer
65 views

Improve the speed of the script with threads

I am trying this code, and it works well, however is really slow, because the number of iterations is high. I am thinking about threads, that should increase the performance of this script, right? ...
1
vote
2answers
40 views

Python-Subprocess-Popen inconsistent behavior in a multi-threaded environment

I have following piece of code running inside thread.. 'executable' produces unique string output for each input 'url': p = Popen(["executable", url], stdout=PIPE, stderr=PIPE, close_fds=True) ...
0
votes
0answers
25 views

PythonWrapper C++ : import variables in local dictionary

Hi I have written the PythonWrapper in C++ with multi-threaded interpreter pool using boost API and python 2.7 C API , The code works fine in 32 bit centos but in case of 64bit It shows weird ...
0
votes
1answer
64 views

Python multithreading: Why generators are not thread-safe? What happens when it is shared among threads?

I'm reading this question which asks if generators are thread-safe, and one answer said: It's not thread-safe; simultaneous calls may interleave, and mess with the local variables. Another ...
3
votes
2answers
81 views

Python: Why different threads get their own series of values from one generator?

I'm learning multithreading in Python. I want to know how to provide data to multiple threads using generators. Here's what I wrote: import threading data = [i for i in xrange(100)] def ...
0
votes
2answers
32 views

Is there any mechanism in Python to control the maximum of multi thread?

I'd like to have something like Executors.newFixedThreadPool(3) which is in Java. That is to say, I want my python program to fork at most 3 multi thread at a time, if the number of multi thread is ...
0
votes
1answer
28 views

python Tkinter, check if root has been destroyed?

I am writing an application using Tkinter along with threading. The problem I got is, after closing the main app, some thread is still running, and I need a way to check whether the root windows has ...
0
votes
2answers
18 views

Kill a tcp connection in a separate thread in Python

So here's the problem, I have a small server script in Python that is supposed to accept multiple clients and based on the message they are sending, receiving a certain command back to them. It's a ...
0
votes
0answers
33 views

Zmq: ZMQError: Interrupted system call on multiprocessing ,while the threading is fine

Can anybody help me find why the threading is work ,and the multiprocessing is not work #!/usr/bin/python #-*- coding:utf-8 -*- import multiprocessing from zmq.eventloop import ioloop, zmqstream ...
2
votes
1answer
24 views

Restart Python with threading or crontab

I have written a function that crawls and clusters news articles. I want this function to restart every 10 minutes, aiming to get the newest articles. I wrote a Python script that this with the help ...
1
vote
0answers
29 views

IRC Client in Python; not a IRC Bot

I've searched extensively on this and only came up with bot specific clients. I know they're basically the same, but for what I want to do I just can't figure it out. I am trying to program a python ...
-1
votes
2answers
35 views

Python interpreter couldn't find the class variable [duplicate]

I am trying to create a distributed hash table. There is a thread. But the run function in the thread cant find the sock variable which I am initializing in the constructor. Here is the code - from ...
0
votes
2answers
39 views

Why are all my threads returned as main?

This script turns ON and OFF 2 Phidgets relays (www.phidgets.com). I wanted to open and close the relays in separate threads. The script below runs but prints each thread as a Main Thread like this ...
0
votes
1answer
21 views

PyMongo: Update, $multi:false, get _id of updated document?

When updating a document in MongoDB using a search-style update, is it possible to get back the _id of the document(s) updated? For example: import pymongo client = pymongo.MongoClient('localhost', ...
0
votes
0answers
16 views

Wrapping Pyro4 name server

I made a class to allow me to start and stop a pyro name server from a script (i.e. not having to start multiple programs such as in the tutorial). The class is as follow: class ...
1
vote
1answer
12 views

Threaded SocketServer not receiving second message

I am trying to implement a simple threaded SocketServer (using SocketServer.ThreadedMixIn). However, my server stops receiving further messages. Here is the code: #!/usr/bin/python -u import ...
0
votes
1answer
25 views

Python Multithreading and databases request?

I'm building a script that use Multithreading.Pool for calling multiple item at once, and I have an odd result. As a starter, here's my (simplified) code, but tested and working (or failing :p) : ...
3
votes
1answer
40 views

A ThreadPoolExecutor inside a ProcessPoolExecutor

I am new to the futures module and have a task that could benefit from parallelization; but I don't seem to be able to figure out exactly how to setup the function for a thread and the function for a ...
0
votes
1answer
37 views

How do I pause a screen scraping process every n iterations?

python devs. I have a conceptual question. I'm writing some screen scraping code that retrieves data from the same website, but with 5,000 hits to the server with a slightly different connection ...
2
votes
1answer
21 views

Why is signal.SIGTERM not dealt with properly in my main thread?

I have python code which runs continuously (collecting sensor data). It is supposed to be launched at boot using start-stop-daemon. However, I'd like to be able to kill the process gracefully, so I've ...
0
votes
1answer
25 views

Mutlithreading - Alternating between two threads using Conditions and Events in Python

I am trying to write a program using which I wish to alternate between two threads, thread1 and thread2. The tricky part is that the thread should begin execution first must be thread1. This is the ...
-1
votes
0answers
24 views

Kill python thread externally from terminal

Is it possible to kill a python thread from the terminal? I'm running Ubuntu and I have code that I need to test with non-daemonic threads. I use eclipse but I suspect killing the process when I find ...
0
votes
1answer
50 views

django connections shared across threads causes ora-01000 maximum open cursors exeeded

I want to stop executing SQL statement if it takes too long to run. To achieve this I hacked django.core.db.backends.oracle.base. In FormatStylePlaceholderCursor.execute and executemany instead of: ...
-4
votes
0answers
32 views

chat, error when sending a message with sockets and threading python [closed]

error when sending a message with sockets and threading program char using the library Tkinter I'm using python 2.7.5 ` from Tkinter import * import socket import threading sock = socket.socket() ...
2
votes
1answer
45 views

should I worry about concurrent access to a dict in a multithreaded python script?

I would like to speed up the execution of a script by launching several threads of independent, asynchronous operations which were otherwise launched one after the other. I used the example from ...
3
votes
1answer
27 views

Threading subprocess and get progress

I'd like to automate handbrake a little bit and wrote a little program in python. Now I have a problem with the subprocess and threading module. I want to dynamically change the number of handbrake ...
0
votes
1answer
35 views

In python, how can I use timeout in subprocess *and* get the output

I used the code in these 2 question how to get the return value from a thread in python subprocess with timeout And got this import subprocess, threading, os class ...
0
votes
1answer
33 views

Python Threading and interpreter shutdown- Is this fixable or issue Python Issue #Issue14623

I have python script that uploads files to a cloud account. It was working for a while, but out of now where I started getting the 'Exception in thread Thread-1 (most likely raised during interpreter ...
1
vote
0answers
68 views

Python read image to numpy array with multiprocessing

I am working on a python program which read a lot of images in batches (let's say 500 images) and store it in a numpy array. Now it's single thread, and IO is very fast, the part which take a lot of ...
0
votes
1answer
38 views

Multithreading - Alternate between two threads using locks

I am trying to write a program using which I wish to alternate between two threads, thread1 and thread2. The tricky part is that I to make sure that the first thread that should begin execution is ...
2
votes
1answer
48 views

Simultaneous parsing, python

I have a python program that sequentially parses through 30,000+ files. Is there a way I could break this up into multiple threads (is this the correct terminology?) and parse through chunks of that ...
1
vote
0answers
61 views
+100

ftplib python: NOOP command works in ASCII not Binary

I have a threaded FTP script. While the data socket is receiving the data, a threaded loop sends NOOP commands to the control socket to keep control connection alive during large transfers. I am ...
0
votes
1answer
37 views

variables duplicated in python threading class

I'm very new to python.. I'm writing a class to create multiple threads for an application that I'm building for my Raspberry Pi (hence the GPIO pins). I have this basically working by pulling some ...
1
vote
5answers
59 views

Explanation of program's behavior (Python)

import threading shared_balance = 0 class Deposit(threading.Thread): def run(self): for i in xrange(1000000): global shared_balance balance = shared_balance ...
1
vote
1answer
32 views

Execute piped command from textfile

I have a text file (songs.txt) containing many lines that look like the quoted text below. What I want is to take apart the left side from the right. The sides will be determined depending on which ...
3
votes
1answer
42 views

running different classes and functions

Im a threading noob. I'm trying to run a function as a thread that weighs something, and another that checks that the weight is sensible -- and shuts down both threads if the weights are not. This is ...
1
vote
0answers
43 views

How to share pandas DataFrame object between processes?

This question has the same point of the link that I posted before. ( Is there a good way to avoid memory deep copy or to reduce time spent in multiprocessing? ) I'm getting nowhere with that since I ...
0
votes
1answer
26 views

Multiple Threads and Python SQL3

I use Python 2.7 and a SQLite3 database. I want to run update queries on the database that can take some time. On the other hand I don't want that the user has to wait. Therefore I want to start a new ...
0
votes
1answer
46 views

Breaking Threaded Loops within Python

I have a small program to ping multiple IPs at the same time via sending 10 pings. This both records the results within a dict and also prints the status to a page. However I want to allow the ...
1
vote
3answers
56 views

I can't understand multithreading using cherrypy/bottle

I'm using bottle with a cherrypy server to utilize multithreading. As I understand it this makes each request handled by a different thread. So given the following code: from bottle import request, ...
1
vote
0answers
19 views

Compute on pandas dataframe concurrently

Is it feasible to do multiple group-wise calculation in dataframe in pandas concurrently and get those results back? So, I'd like to compute the following sets of dataframe and get those results ...
0
votes
3answers
57 views

Python Threading inside class

I recently started with python's threading module. After some trial and error I managed to get basic threading working using the following sample code given in most tutorials. class ...
0
votes
0answers
26 views

In Oracle, how han I cancel broken connection?

This code is in python but basically it's using OCI so should be reproducible in any other language: import cx_Oracle as db dsn = '(DESCRIPTION ...
4
votes
1answer
55 views

Garbage-collect a lock once no threads are asking for it

I have a function that must never be called with the same value simultaneously from two threads. To enforce this, I have a defaultdict that spawns new threading.Locks for a given key. Thus, my code ...

15 30 50 per page