3
votes
0answers
26 views

How can I reproduce concurrency bugs in this python code reliably?

Context I recently posted a timer class for review on Code Review. I'd had a gut feeling there were concurrency bugs as I'd once seen 1 unit test fail, but was unable to reproduce the failure. Hence ...
0
votes
0answers
18 views

Spawn a long running process and keep getting STDOUT

I am trying to run a remote command using paramiko. Think of it as a small scale job scheduler managed from just 1 machine to 8-9 machines. Currently: 1. The webapp spawns process1 2. process1 ...
0
votes
2answers
31 views

threading in Python taking up too much CPU

I wrote a chat program and have a GUI running using Tkinter, and to go and check when new messages have arrived, I create a new thread so Tkinter keeps doing its thing without locking up while the new ...
0
votes
0answers
11 views

TNonblockingServer in thrift crashes when TFramedTransport opens

I've been trying to implement a thrift server in C++ to communicate with a Python client. here is my code: C++ server: shared_ptr<ThriftHandler> _handler (new myHandler()); ...
0
votes
0answers
19 views

how to code Multi threading a for loop curve fitting

I have a "for loop" that runs over 100 range values and for each value, I call scipy.optimize to do a non-linear curve fitting. When I run it on a 4-core desktop, I see the CPU utilization as 100% ...
0
votes
1answer
19 views

In this case , how can i write the queue.put

I'm writing a program to get the domain in same server and it also can scan the web directory. #!/usr/bin/env python #encoding = utf-8 import threading import urllib,urllib2,httplib from urllib2 ...
1
vote
0answers
23 views

Embedding Python Interpreter, sub interpreter, multi threading

This is not a question. I think there is very less information about embedding Python interpreter. I am starting this discussion to help those developer who want to embed Python interpreter, sub ...
2
votes
1answer
40 views

How to end a program properly with threads?

I have a class which pulls items from a queue and then runs code on it. I also have code in the main function that adds items to the queue for processing. For some reason, the program doesn't want to ...
0
votes
0answers
20 views

Python Threading Notify Consumer Threads

I writing a producer consumer program in python. Below is my code. Currently I have used an if condition in my consumer, but I want that as soon as producer finishes producing items, my consumers ...
0
votes
1answer
30 views

python - join all threads after start_new_thread

When using the thread library, Is there a way to join all threads that were created by start_new_threads ? for example: try: import thread except ImportError: import _thread as thread ...
1
vote
2answers
27 views

handling errors from unix commands when called from Popen

I have the following method I'm using to test the bc unix command ... it takes an expression, executes it and takes the output back ... def run_test(expr=""): try: process = ...
0
votes
1answer
46 views

Is Django's “Model” API thread-safe?

Specifically, I'm only talking about modifying separate instances of a Model (not sharing the same exact instance) across threads. But is it safe to be calling save() from one thread, while multiple ...
1
vote
0answers
51 views

Python function call in thread always returns same value

I'm boggled over why a function called in a thread always returns the same value. I've confirmed that the parameters are different for each call. If I call the function after acquiring a lock then the ...
0
votes
0answers
29 views

Threaded BaseHTTPServer, one thread per request

I'm trying to create an multi-threaded web server using BaseHttpServer and ThreadingMixIn (as seen on various examples). Pseudo code would be something like: class Handler(BaseHTTPRequestHandler): ...
0
votes
1answer
32 views

Killing thread in python

I defined class A which has a method like this. def func(self): while True: threading.Timer(0,self.func2, ["0"]).start() time.sleep(nseconds) threading.Timer(0,self.func2, ...
13
votes
0answers
210 views

My numpy build doesn't use multiple CPU cores

Note: Read this question carefully. I understand that CPython has the GIL. Numpy is normally not limited by the GIL for most functions. Update: This turns out to be the same issue described in this ...
0
votes
1answer
27 views

subprocess.call() do not wait when called from thread

i have a problem with subprocess.call() which do not wait when called from inside a thread. here is the code that i'm using: import time from PyQt4 import QtCore, QtGui import sys import subprocess ...
1
vote
2answers
32 views

Multithreading With Python Turtle

Is there a way to use two turtles at the same time to draw two circles at the same time in one window? I tried this code but two turtles draw in separated windows from multiprocessing import Process ...
0
votes
2answers
60 views

PyQt4: Conventional multithreaded UI over Signal/Slot mechanism?

Anyone who has worked with Multithreaded PyQt4 apps? I was just wondering if the inbuilt signal/slot mechanism coupled with QtThread of PyQt4 framework has any benefit over the standard Python threads ...
0
votes
0answers
14 views

WorkerPool stops after Exception was raised

I have this code: folder = "/Users/foreigner/PycharmProjects/Selenium/urls1" files = [f for f in listdir(folder) if isfile(join(folder, f))] class DownloadJob(workerpool.Job): def ...
0
votes
1answer
40 views

Python _thread Have each thread process the respective number in a sequence

I really don't know to word it much better. I want the first thread to process the first one and the fifth and the ninth, the second would get the second-sixth-tenth,third-seventh,eleventh, and the ...
0
votes
1answer
39 views

Python Error :UnboundLocalError: local variable 'f' referenced before assignment

I'm trying to process some files using threading in Python.Some threads work fine with no error but some through the below exception Exception in thread Thread-27484: Traceback (most recent call ...
0
votes
4answers
35 views

Threading in Python not working as expected

I'm trying to process my files in a directory using threading.Being new to threads i expected each thread to process a file separately.But the program is waiting until one file has been processed.The ...
0
votes
2answers
19 views

An error with queue.get, bool object has no attribute get

#!/usr/bin/env python #coding=utf-8 import sys,os,threading import Queue keyword = sys.argv[1] path = sys.argv[2] class keywordMatch(threading.Thread): def __init__(self,queue): ...
1
vote
2answers
45 views

Reading files using different threads

I'm trying to read and modify each row of a number of files using Python. Each file has thousands to lakhs of rows and hence each file is processed only after another one if processed. I'm trying to ...
1
vote
1answer
29 views

python : print output of each thread to seperate file

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. What I mean is the following: ...
0
votes
2answers
66 views

Run server alongside infinite loop in Python

I have the following code: #!/usr/bin/python import StringIO import subprocess import os import time from datetime import datetime from PIL import Image # Original code written by brainflakes and ...
0
votes
1answer
23 views

Query whether Python's threading.Lock is locked or not

I have a thread I am running (code below) which launches a blocking subprocess. To ensure that other threads do not launch the same subprocess, I have a lock around this subprocess.call call. I also ...
1
vote
1answer
26 views

Python cancel raw_input/input via writing to stdin?

For starters, I'm on python 2.7.5 and Windows x64, my app is targeted at those parameters. I'm in need of a way to cancel a raw_input after a certain amount of time has passed. Currently I have my ...
1
vote
1answer
47 views

Pythonic way for managing thread pool

I have a couple of python scripts that are responsible for managing some live feed processing. Its structured like so: Script 1: manages an "aggregate" list of live events that provides some very ...
0
votes
1answer
27 views

Call function in wx.frame from different class in Python

There are very similar questions but I'm either not understanding them or they don't quite answer them. The one two I have seen are this one and this one. I have a wxpython GUI running. On the ...
0
votes
0answers
17 views

Thread-Switching in PyDbg

I've tried posting this in the reverse-engineering stack-exchange, but I thought I'd cross-post it here for more visibility. I'm having trouble switching from debugging one thread to another in ...
0
votes
2answers
27 views

Python threading.stack_size() has no effect

I am trying to reduce the stack size for a python script in order to produce more threads. I am setting it like this threading.stack_size(32768) And putting it at the import level, before any ...
0
votes
1answer
32 views

How to terminate thread in python

Here I am creating 3 threads for one server and 2 clients. I wanted to stop the thread and make the port numbers reusable after one execution. My code is t1=threading.Thread(target=serv) ...
15
votes
2answers
282 views
+50

input() blocks other python processes in Windows 8 (python 3.3)

Working on a multi-threaded cross-platform python3.3 application I came across some weird behavior I was not expecting and am not sure is expected. The issue is on Windows 8 calling the input() method ...
1
vote
1answer
46 views

Why threading.stack_size() does not produce the effect wanted?

I am using Python 2.7 x86 on Windows 7 x64. I would like to stick with Python 2.7 for x86 for now as the applications I code will be used on mostly x86 machines anyway. Right now, the script I am ...
0
votes
0answers
17 views

Wrapping Pyro's NameServer the correct way

I'm trying to warp Pyro's name server into a more convenient object that would allow me to start and stop it as I wish. For example, I would like to be able to do something like nameServer = ...
0
votes
1answer
48 views

Real time plotting with Matplotlib, PyQt and Threading ends to python crash

I've been struggling with my Python application and I can't find any answers. I'm having PyQT GUI application which uses Matplotlib widget. GUI starts a new thread which handles plotting to mpl ...
0
votes
1answer
26 views

Signal the end of jobs on the Queue?

Here's an example code of from Python documentation: def worker(): while True: item = q.get() do_work(item) q.task_done() q = Queue() for i in range(num_worker_threads): ...
-1
votes
1answer
43 views

Threading help needed

Any ideas on how to get this code to work? I am using windows 7 and python 3.3.2 from tkinter import * class Clock: def _init_(self, parent): self.parent = parent self.x = 0 self.y = 0 ...
1
vote
0answers
45 views

Can multiple threads be created to handle multiple task in python?

Can a thread be created to keep the queue populated with lines from the source file, text.txt, as well as simultaneously write the results to the output file tagfile.csv when the tagreset value is ...
0
votes
3answers
44 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 ...
1
vote
1answer
33 views

Multiprocessing in Python with read-only shared memory?

I have a single-threaded Python program, and I'd like to modify it to make use of all 32 processors on the server it runs on. As I envision it, each worker process would receive its job from a queue ...
4
votes
2answers
60 views

How to properly stop python threads?

I'm new in Python. This is my code: import logging logging.basicConfig(level = logging.DEBUG, format = "[%(levelname)s] (%(threadName)-10s) %(message)s") import threading import time def thread1(): ...
0
votes
4answers
51 views

Run method on Python Bottle server shutdown

I'm working on a small python app controlled by a web page via the Bottle framework. Problem is that I am sometimes running threads in the background but if the Bottle instance is shutdown, via Ctrl+C ...
0
votes
2answers
46 views

Multithreading (?): Manual interference in a loop

I've been looking into a way to directly change variables in a running module. What I want to achieve is that a load test is being run and that I can manually adjust the call pace or whatsoever. ...
0
votes
2answers
37 views

File monitoring in osx 10.8.2 using python

I am using a file monitor to listen to the changes in a file using win32file monitor. This below code works fine on windows. This code does not work on mac osx. Any suggestions for making a file ...
0
votes
1answer
102 views

Multi-threaded websocket server on Python

Please help me to improve this code: import base64 import hashlib import threading import socket class WebSocketServer: def __init__(self, host, port, limit, **kwargs): """ ...
1
vote
1answer
30 views

Threading and Django db create operations

I have a python script which collects information for actors from various APIs (wikipedia, tmdb and imdb) then adds them to a postgresql database. It worked well but was sometimes a little slow due to ...
1
vote
0answers
38 views

Is there a more elegant way to clean up thread references in python? Do I even have to worry about them?

I am working with QThreads from pyqt4. I have a thread that is always running, let's call it main. In the constructor, main initializes an empty list. I spawn child threads from main by appending them ...

15 30 50 per page