Tagged Questions
0
votes
1answer
11 views
python ftplib transfercmd() BINARY Mode
in the absence of an answer to my previous question.
I am using multihtreading to keep a large FTP transfer alive via the control socket.
Unfortuantely this requires the use of ...
0
votes
1answer
19 views
Python threading only launching one extra thread
import socket
import thread
s = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
s.connect(("server", 6661))
def recv():
while 1:
print(s.recv(1024))
def send():
while 1:
...
1
vote
1answer
17 views
How to use a separate thread for asynchronous signal handling in python
Below is my test code.
When running with python2.7 it shows that the program won't receive any signal until all spawned threads finish.
While with python3.2, only the main thread's sigintHandler gets ...
4
votes
2answers
56 views
How Do I Queue My Python Locks?
Is there a way to make python locks queued? I have been assuming thus far in my code that threading.lock operates on a queue. It looks like it just gives the lock to a random locker. This is bad for ...
2
votes
1answer
37 views
Python return value from scheduled event
I would like to get the value returned from a function called by a scheduled event. Below is a simple example of what I would like to do.
import time
import sched
schedule = ...
1
vote
1answer
30 views
multi threading in python
I have a program or function printValue() that prints some value. But it takes some time(say 5 min) to execute the function. So, How can I implement multithreading or some technique in python so that ...
0
votes
0answers
17 views
Removing print, make the app crash on multithread app
I was reading about Python thread tutorial, from Threads in Python, please note that the asterics marked lines. If I run more than one thread and comment the marked lines, the program crashes ...
1
vote
0answers
17 views
Memcache client with connection pool for Python?
python-memcached memcache client is written in a way where each thread gets its own connection. This makes python-memcached code simple, which is nice, but presents a problem if your application has ...
2
votes
1answer
20 views
Plotting with matplotlib in threads
I know there are quite some questions on matplotlib and threading, also that pyplot is not threadsave. I couldn't find anything on this particular problem however. What I want to do is: plot a figure ...
1
vote
2answers
40 views
Python program with thread can't catch CTRL+C
I am writing a python script that needs to run a thread which listens to a network socket.
I'm having trouble with killing it using ctrl-c using the code below:
#!/usr/bin/python
import signal, ...
0
votes
1answer
19 views
Openerp Timer task using python Threads
Please can anyone give me a example for OpenERP [python] threads.
my requirement is Need to read attendance [text based file] hourly and store it and backup
i searched in forums & workspace also ...
0
votes
1answer
40 views
Execute multi threaded program in Python to run as single thread
I've been using threading class alot in my Python codes and have successfully make a couple routine to run as multi-threaded. The problem is when something fails, it becomes a pain when it comes to ...
0
votes
0answers
31 views
Without the join method from the Thread class, how to block the calling thread without blocking event handlers? Python Tkinter Timer
Well guys, sorry for the thread's title. It's kind of confusing but I think it's gonna be easier to understand what I'm trying to do with this
from Tkinter import *
from threading import Timer
class ...
1
vote
1answer
17 views
Pool.map just hangs — how to do exception handling
I have the following code:
pool = Pool(10)
pool.map(run_update_procedure, titles_to_update)
Sometimes the pool.map will only work on about 18 of the 20 titles above. This causes the program to ...
0
votes
3answers
53 views
How to run max 10 threads in one time?
I want to make 1000 request to a single serwer.
I use threading modul but server block me.
How to set thread that run only max 10 thread in one time (form a list of 1000)?
1
vote
0answers
66 views
Is there a good way to avoid memory deep copy or to reduce time spent in multiprocessing?
I am making a memory-based real-time calculation module of "Big data" using Pandas module of the Python environment.
So response time is the quality of this module and very critical and important.
...
5
votes
1answer
57 views
Python threads don't run simultaneously
I'm brand new to multi-threaded processing, so please forgive me if I butcher terms or miss something obvious.
The code below doesn't offer any time advantage over different code that calls the same ...
1
vote
2answers
29 views
list/array of sockets in python
I am kind of new to python. I am currently trying to make and use a list/array of sockets in a program. So I have declared an array as follows:
myCSocks = ['CSock1', 'CSock2', 'CSock3', 'CSock4', ...
1
vote
1answer
30 views
Can not catch exception in threaded program
The Python program below starts one thread and then continues to perform actions in the main thread. I wrap the whole main thread in a try-except block so I can tear down all running threads if an ...
0
votes
1answer
30 views
threading a bottle app
I have a simple bottle script that forwards button processes on a web page. Within the same script I was looking to have a continuous loop that among other tasks listened out for these button presses. ...
3
votes
0answers
65 views
How can I reproduce the race conditions 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
2answers
40 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
1answer
39 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
1answer
25 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
21 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
29 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
32 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
50 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, ...
15
votes
2answers
276 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
34 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
39 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
73 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
16 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
41 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
48 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
24 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
46 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
36 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
70 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
25 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
29 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
49 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
32 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 ...