multiprocessing

Java respawn process

I'm making an editor-like program. If the user chooses File->Open in the main window I want to start a new copy of the editor process with the chosen filename as an argument. However, for that I need to know what command was used to start the first process: java -jar myapp.jar blabalsomearguments // --- need this information > Open File...

Writing a search engine

Hello all, The title might be a bit misleading, but I couldn't figure out a better title. I'm writing a simple search engine which will search on several sites for the specific domain. To be concrete: I'm writing a search engine for hardstyle livesets/aftermovies/tracks. To do I will search on the sites who provide livesets, tracks, and...

Python multiprocessing/threading with shared variables that only will be read

Considering the code below. I would like to run 3 experiments at a time. The experiments are independent, the only thing they share is the Model object which they only read. As there are seemingly no hard things in threading this out, how can I best do this in Python? I would like to use a pool or so to make sure that only three experim...

How likely are two processes to grab a "free" directory?

If I have a multiprocess system that needs to process a bunch of directories, 1 directory per process, how likely is it that two processes will happen to grab the same directory? Say I have dir/1 all the way to dir/99. I figure that if I touch a .claimed file in the dir that the process is working on, there won't be conflicts. Are there...

How to run a clean up when terminating Python script

I have a python scripts that does some jobs. I use multiprocessing.Pool to have a few workers do some commands for me. My problem is when I try to terminate the script. I would like when I press Ctrl-C, that every worker immediately cleans up it's experiment (which is some custom code, or actually even a subprocess command, not just rel...

Implementing a special type of multiprocessing queue in Python

Imagine an inverted binary tree with nodes A, B, C, D, E, F on level 0. nodes G,H,I on level 1, node J on level 2, and node K on level 3. Level 1: G = func(A,B), H = func(C,D), I = func(E,F) Level 2: J = func(G,H) Level 3: K = func(J,I). Each pair of nodes on Level 0 must be processed in order, Each pair of nodes on Level 1 can be ...

Python multiprocessing.Queue deadlocks on put and get

I'm having deadlock problems with this piece of code: def _entropy_split_parallel(data_train, answers_train, weights): CPUS = 1 #multiprocessing.cpu_count() NUMBER_TASKS = len(data_train[0]) processes = [] multi_list = zip(data_train, answers_train, weights) task_queue = multiprocessing.Queue() done_queue = mu...

python threading and queues for infinite data input (stream)

Hi All, I would like to use thread to process a streaming input. How can make the below code for an infinite input generate for example by using itertools.count The code below will work if: 'for i in itertools.count():' is replaced by 'for i in xrange(5):' from threading import Thread from Queue import Queue, Empty import itertools...

How to call process by name or tags in python

I am using multiprocessing module. This module is works on Queue that is its pick random process and assign the entery from Queue. I want to decide which process will work on which entry of Queue Here is my requirements, I will pass 2 parameters to queue Initiator Process name Action/method ( What process is going to do) Its sh...

How do you pass a Queue reference to a function managed by pool.map_async()?

I want a long-running process to return its progress over a Queue (or something similar) which I will feed to a progress bar dialog. I also need the result when the process is completed. A test example here fails with a RuntimeError: Queue objects should only be shared between processes through inheritance. import multiprocessing, time ...

How does event driven I/O allow multiprocessing?

I am aware of event driven I/O like select, poll, epoll, etc allow someone to build say a highly scalable web server, but I am confused by the details. If there is only one thread of execution and one process running for the server, then when the server is running its "processing" routine for the ready clients, isn't this done in a seria...

Path.GetTempFileName in MultiProcessing

Hi, we run several instances of our program (c#) on a single computer. In each instance our code tries to create "many" temporary files with help of method Path.GetTempFile(). And sometimes, our program fails with exception: Exception: Access to the path is denied. StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String ...

making python programs "chat" via pipe

Hi! I'm trying to make two processes communicate using a pipe. I did this in the parent process: process = subprocess.Popen(test, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE) process.stdin.write("4\n"); output = process.stdout.read() print output and in the child process: inp = raw_input() integer = int(inp) print int...

Multiprocessing: using Pool.map on a function defined in a class

Hi, when i run something like from multiprocessing import Pool p = Pool(5) def f(x): return x*x p.map(f, [1,2,3]) it works fine. However, putting this as a function of a class class calculate(object): def run(self): def f(x): return x*x p = Pool() return p.map(f, [1,2,3]) cl = calculate() print cl.run() gives me ...

Parallel programming using python's multiprocessing and process defunc

Hi there, I have a problem with creating parallel program using multiprocessing. AFAIK when I start a new process using this module (multiprocessing) I should do "os.wait()" or "childProcess.join()" to get its' exit status. But placing above functions in my program can occur in stopping main process if something happens to child process...

IPC (inter process communication) between python and java

Hello, First, a little explanation of why I'm asking this question in the first place: I'm writing a python program (with a wxPython gui) that needs to call a Java AWT program from python and extract data from it. I have an in-process working solution on Windows. I also have an in-process solution on OSX so long as I run the Java app he...

question comparing multiprocessing vs twisted

Hi. Got a situation where I'm going to be parsing websites. each site has to have it's own "parser" and possibly it's own way of dealing with cookies/etc.. I'm trying to get in my head which would be a better choice. Choice I: I can create a multiprocessing function, where the (masterspawn) app gets an input url, and in turn it spans...

python: simple approach to killing children or reporting their success?

I want to call shell commands (for example 'sleep' below) in parallel, report on their individual starts and completions and be able to kill them with 'kill -9 parent_process_pid'. There is already a lot written on these kinds of things already but I feel like I haven't quite found the elegant pythonic solution I'm looking for. I'...

python multiprocessing does not work

I don't understand why this simple code # file: mp.py from multiprocessing import Process import sys def func(x): print 'works ', x + 2 sys.stdout.flush() p = Process(target= func, args= (2, )) p.start() p.join() p.terminate() print 'done' sys.stdout.flush() creates "pythonw.exe" processes continuously and it doesn't print a...

Two Spinlocks on same processor ?

Can two CPUs hold two "different" spin locks simultaneously at same time? So...does this mean: a sigle(uniprocessor) CPU cannot hold two "different" spinlocks at the same time? So...does this mean: the number of spinlocks on a single CPU cannot be > 1. PS:"different" implying spinlock associated with different memory resources. Doe...