Tagged Questions
0
votes
1answer
21 views
Python equivalent of Java's `tryLock` (idiomatic)?
In Java tryLock(long time, TimeUnit unit) can be used as a non-blocking attempt to acquire the lock. How can the equivalent in python be achieved? (Pythonic | idiomatic way is preferred!)
Java ...
0
votes
2answers
47 views
Python Threads not finishing
I'm currently testing something with Threading/ workpool; I create 400 Threads which download a total of 5000 URLS... The problem is that some of the 400 threads are "freezing", when looking into my ...
0
votes
0answers
12 views
SqlAlchemy in threads in Twisted
I'm building a Twisted application in Python 2.7 and am trying to use SqlAlchemy to interact with the database. I've got a working application that is leaking memory, and am not sure how to find the ...
0
votes
1answer
14 views
Python 3.3 Multithreading argument sequence
I have been making a small piece of code to test threading while a FOR loop is running, and also running different functions in a different class.
The code works very well, except that if you want it ...
4
votes
1answer
78 views
Python: How do you stop numpy from multithreading?
I know this might seem like a ridiculous question, but I have to run jobs on a regular basis on compute servers that I share with others in the department and when I start 10 jobs, I really would like ...
0
votes
1answer
63 views
Why this multi-threaded code is executed 5x more than it should? [closed]
I don't understand why this simple python example is executed 5x time more than it should :/ I looked at the code for 2h, searched on Google ect... I really don't see the problem here. Any help would ...
0
votes
1answer
30 views
Digital clock display - multithreading required?
Situation
I have the following Tkinter window:
And in the blank space on the right:
I want to be able to continuously update the time, like on a digital clock.
I will take the present time ...
1
vote
1answer
33 views
Python Saving Process (closing the file handler)
Please Review this basic example
def queue_add():
#this will exit when all lines from the
#file are added in the Queue
with open('get_from.txt') as f:
for line in f:
...
1
vote
0answers
46 views
Dependency Contradiction in code generator
My current project is to attempt to port the popular card game Mao into a LAN game (multiplayer) where the computer will be the 'Grand Master.' It will keep track of the rules, the deck, the players, ...
1
vote
2answers
65 views
Python threading questions
I have something like the following:
d = {...} #a dictionary with strings
l1 = [...] #a list with stuff
l2 = [...] #a list with numbers
...
for i in l1:
for key in l2:
#do some stuff
...
2
votes
2answers
57 views
Faking an insertion in Python Queue
I'm using a Queue in python, and it works something like a channel. That is, whenever you make an insertion, some other thread is waiting and fetches the inserted value. That value is then yield.
...
0
votes
0answers
33 views
Python program misbehavior when spawning processes from a py2exe file
My dad is working on a program that, among others, needs to ping a machine. It is multithreaded and he built a ping method that's be called from any one of the threads, when needed:
def ping_cmd(ip):
...
0
votes
1answer
37 views
python parallelism for uploading files
my problem is the following : my application needs to upload multiple files simultaneously to S3 using the Boto library in python. I've worked out 2 solutions, but I'm not sure of the implications of ...
0
votes
3answers
66 views
Command line multithreading
I am writing a simple command-line program that shows the current time and let user set the alarm. However, the alarm did not ring as the raw_input was blocking it. I have even implement ...
0
votes
0answers
37 views
Concurrency and flask
First of all what I describe below probably isn't efficient, but it's just for self learning.
Anyway, I'm using a producer and consumer threads to get data from an API.
I plan on using Flask to ...
1
vote
0answers
31 views
In Python, does DummyThread uniquely identify the current thread?
Edit: by multithreading, I mean I've set threadsafe: true in my app.yaml, not that I am trying to create my own threads.
I've been trying to use multithreading in my GoogleAppEngine Python ...
4
votes
3answers
46 views
What is the best way to download <very large> number of pages from a list of urls?
I have a >100,000 urls (different domains) in a list that I want to download and save in a database for further processing and tinkering.
Would it be wise to use scrapy instead of python's ...
1
vote
2answers
70 views
Segmentation fault in python?
I'm creating GUI using gtk3. So that the GUI and operation works together, I make a thread with this code: threading.Thread(target=function).start(). Without threading, everything works well, but the ...
0
votes
1answer
19 views
PyQt GUI control access from another thread
i'm trying to create an client server application in python. When the server closes i wish the gui of the client wich is on a separate thread to close, but the application crushes with Xlib error: bad ...
0
votes
2answers
48 views
Python: How to use threads in network?
I am trying to make a program that will search random ids for
site titles. I made a one threaded function but it is super slow
because it has to wait for timeout if there is no server at random
ip. I ...
0
votes
3answers
49 views
Adding the ability for a python Thread to report when finished
I am currently subclassing python's threading.Thread class in order to add additional logging features to it. At the moment I am trying to get it to report both when the thread is started, and when ...
0
votes
2answers
59 views
How to do background task in gtk3-python?
I have this main thread:
Gui.py
from gi.repository import Gtk, Gdk
import Process
import gobject
class gui():
def __init__(self):
self.window = Gtk.Window()
...
2
votes
2answers
48 views
Python logging from multiple threads
I have a log.py module, that is used in multiple at least two other modules (server.py and device.py).
It has these globals:
fileLogger = logging.getLogger()
fileLogger.setLevel(logging.DEBUG)
...
1
vote
2answers
58 views
Calculation of Pi with multiple threads( no acceleration - what to do )
I'm trying to calculate pi with arbitrary precision on Python using one of Ramanujan's formulas: http://en.wikipedia.org/wiki/Approximations_of_%CF%80#20th_century. It basically requires lots of ...
1
vote
1answer
22 views
How to access GUI elements from another thread in PyQt
I'm trying to create a client-server application, and when the server closes I wish that client GUI to close, wich is running on another thread. I wish to access the GUI and close but I get X error : ...
0
votes
1answer
42 views
How to implement non blocking socket server in python
A similar but different question:
I have an IRC client that generates strings. This IRC client uses a hook to call a method (somone_said) whenever someone says something. I want to send this string ...
0
votes
1answer
44 views
Calling a python function in the background
Question
I need to be able to call a function in the background without it freezing the console. I have experience with multithreading, but I would prefer if it completed tasks in order. What's the ...
0
votes
1answer
27 views
How to use queue with concurrent future ThreadPoolExecutor in python 3?
I am using simple threading modules to do concurrent jobs. Now I would like to take advantages of concurrent futures modules. Can some put me a example of using a queue with concurrent library?
I am ...
-1
votes
0answers
28 views
python crash after running a long time
The following is the back trace i got from gdb:
Thread 14 (Thread 7752.0x23c8):
#0 0x7798000d in ntdll!LdrFindResource_U () from C:\Windows\SysWOW64\ntdll.dll
#1 0x77a0f896 in ...
0
votes
0answers
26 views
how to run two separate threads with twisted reactor in Linux by having virtualenv?
how to run two separate threads with twisted reactor in Linux by having virtualenv ?
the virtualenv has Python 2.7.4
the application is calling " reactor.callInThread(self._checkForNewMessage) " ...
0
votes
1answer
224 views
Lisp and global interpreter lock [closed]
Python's global interpreter lock is well known discussed problem. But the analogous problem for Lisp doesn't seem to have any discussion.
Both Python and Lisp are dynamic languages. But why does Lisp ...
0
votes
2answers
58 views
Debugging a Python script that randomly hangs and uses 100% of a processor core
I'm currently working on a fairly complex multithreaded Python script. There is one main function that is run in about 5 threads at a time. I've been having some issues with it hanging and using 100% ...
5
votes
3answers
86 views
Basic threading in python
OK the code is pretty basic. Since I'm using multiple threads, and I want shared variables between them, I'm using a global.
Why does the code in ThreadClass sometimes not execute when I hit "C"? I ...
2
votes
1answer
43 views
Run a python socket server and if closed remotely start it listening again
I am struggling to get my python socket to behave.
There are two major problems:
1) When it listens for the client connection the program stalls which is a problem because it is running on a IRC ...
2
votes
1answer
39 views
Controlling Thread Execution Time in Python
Is it possible to control the proportional execution time of a thread in python. For example, I have three functions F1, F2 and F3 in my program. I am calling each function with using start_new_thread ...
0
votes
0answers
35 views
Python Twisted Multiple Client Objects
Would this be the appropriate way to create multiple clients on a single machine?
def main():
threads = [None]*10
for i in range(0, 10):
threads[i] = ClientFactory()
...
1
vote
2answers
29 views
Python twisted irc: Wait for a whois reply inside privmsg method
im trying to make an irc bot using the twisted.words.protocols.irc module.
The bot will parse messages from a channel and parse them for command strings,
everything works fine except when i need the ...
0
votes
1answer
114 views
Efficient Python programming for 4-core PC with threading?
I'm looking to write a script to explore the parameter space in some simulation software. Initially, I just want to run the simulation script, say, 100 times, each time incrementing one parameter.
...
2
votes
1answer
59 views
Is getattr/setattr/hasattr/delattr thread safe?
See this Singleton implementation:
if not hasattr(Singleton, "_instance"):
with Singleton._instance_lock:
if ...
0
votes
3answers
47 views
Kill a running subprocess call
I'm launching a program with subprocess on Python.
In some cases the program may freeze. This is out of my control. The only thing I can do from the command line it is launched from is Ctrl-Esc which ...
1
vote
1answer
30 views
Variable loops and synchronization
def start(self):
self.running = True
while self.running:
pass
def shut_down(self):
self.running = False
Hi i want to knew a good way, to synchronise variable running. I want to ...
0
votes
1answer
31 views
Python Tkinter Multithreading functions
I am currently working on an Email sender and recieving program with the tkinter library from python.
I am using the threading module to make the program refresh the unread emails every 60 seconds ...
2
votes
1answer
48 views
Need a thread-safe asynchronous message queue
I'm looking for a Python class (preferably part of the standard language, rather than a 3rd party library) to manage asynchronous 'broadcast style' messaging.
I will have one thread which puts ...
0
votes
1answer
36 views
Running two while statements at same time with Threads and Queue
I am trying to run two or more while statements in functions at the same time with Threads and queueing.
However i'm struggling to get my head around how the queues work and the proper syntax. OR ...
0
votes
0answers
20 views
Mandrill sends repeated emails with django mailsnake
I have a function that runs every hour with apscheduler, this verifies few conditions and according to this sends an email to an arrangement of emails
from mailsnake import MailSnake
mapi = ...
2
votes
2answers
44 views
experimenting with python threads, how to stop thread
watching David beazley's(http://www.dabeaz.com) video about python threads,I was trying out stuff with threads
def countdown(n):
while n > 0:
if not n % 100000:
print n
...
0
votes
1answer
23 views
Can't catch pickle error
I have a thread that constanlty waits for input via a socket. It receives things fine, but if I try to pickle.loads the string, then I receive an error. That would be an easy thing to catch, but this ...
0
votes
0answers
23 views
check dependency of 2 functions python
check dependency of 2 functions python. for example the result of one function is used as parameter in the or function. but the 2 function will not be process together. i am using parallel processing ...
2
votes
1answer
47 views
Python: Can I use class variables as thread locks?
I was thinking about using a class variable as a thread lock, since I don't like to define a lock within the global variables and also want to prevent deadlock. Does this actually work? Example:
...
0
votes
0answers
23 views
Bottle Web Framework: How to rerun the script for certain event
When run bottlepy using WSGI Server, I can restart the server by pressing ctrl+c and run the script one more time.
However I want to do this automatically. So whenever files/directories added, ...