@

Home 

python Programming Glossary: queue

Solving embarassingly parallel problems using Python multiprocessing

http://stackoverflow.com/questions/2359253/solving-embarassingly-parallel-problems-using-python-multiprocessing

can run independently. Part 1 can place data on an input queue part 2 can pull data off the input queue and put results onto.. data on an input queue part 2 can pull data off the input queue and put results onto an output queue and part 3 can pull results.. data off the input queue and put results onto an output queue and part 3 can pull results off the output queue and write them..

python multithreading for dummies

http://stackoverflow.com/questions/2846653/python-multithreading-for-dummies

to resolve and respond in order to put its contents on the queue each thread is a daemon won't keep the process up if main thread.. the main thread starts all subthreads does a get on the queue to wait until one of them has done a put then emits the results..

Which game scripting language is better to use: Lua or Python? [closed]

http://stackoverflow.com/questions/356160/which-game-scripting-language-is-better-to-use-lua-or-python

semaphores a Lua library. Then in Lua I wrote an atomic queue abstraction that I used to balance workloads across a server..

Non-blocking read on a subprocess.PIPE in python

http://stackoverflow.com/questions/375427/non-blocking-read-on-a-subprocess-pipe-in-python

try from Queue import Queue Empty except ImportError from queue import Queue Empty # python 3.x ON_POSIX 'posix' in sys.builtin_module_names.. 3.x ON_POSIX 'posix' in sys.builtin_module_names def enqueue_output out queue for line in iter out.readline b'' queue.put.. 'posix' in sys.builtin_module_names def enqueue_output out queue for line in iter out.readline b'' queue.put line out.close p..

Stop reading process output in Python without hang?

http://stackoverflow.com/questions/4417962/stop-reading-process-output-in-python-without-hang

thread and save the required number of the last lines in a queue import collections import subprocess import time import threading..

Catch a thread's exception in the caller thread in Python

http://stackoverflow.com/questions/2829329/catch-a-threads-exception-in-the-caller-thread-in-python

Try this on for size import sys import threading import Queue class ExcThread threading.Thread def __init__ self bucket threading.Thread.__init__.. Exception self.bucket.put sys.exc_info def main bucket Queue.Queue thread_obj ExcThread bucket thread_obj.start while True.. self.bucket.put sys.exc_info def main bucket Queue.Queue thread_obj ExcThread bucket thread_obj.start while True try..

python multithreading for dummies

http://stackoverflow.com/questions/2846653/python-multithreading-for-dummies

return the contents of the first one to respond. import Queue import threading import urllib2 # called by each thread def.. .read theurls '''http google.com http yahoo.com'''.split q Queue.Queue for u in theurls t threading.Thread target get_url args.. theurls '''http google.com http yahoo.com'''.split q Queue.Queue for u in theurls t threading.Thread target get_url args q u..

Python urllib2.urlopen() is slow, need a better way to read several urls

http://stackoverflow.com/questions/3472515/python-urllib2-urlopen-is-slow-need-a-better-way-to-read-several-urls

his code using modern Python modules like threading and Queue. import threading urllib2 import Queue urls_to_load 'http stackoverflow.com.. like threading and Queue. import threading urllib2 import Queue urls_to_load 'http stackoverflow.com ' 'http slashdot.org '.. s' len data url queue.put data def fetch_parallel result Queue.Queue threads threading.Thread target read_url args url result..

Non-blocking read on a subprocess.PIPE in python

http://stackoverflow.com/questions/375427/non-blocking-read-on-a-subprocess-pipe-in-python

without blocking on both Windows and Linux is to use Queue.get_nowait import sys from subprocess import PIPE Popen from.. import PIPE Popen from threading import Thread try from Queue import Queue Empty except ImportError from queue import Queue.. Popen from threading import Thread try from Queue import Queue Empty except ImportError from queue import Queue Empty # python..

How to improve performance of this code?

http://stackoverflow.com/questions/4295799/how-to-improve-performance-of-this-code

user 0m20.549s sys 0m0.020s Here's the code import Queue fCamel 'F' bCamel 'B' gap 'G' def solution formation return.. astar formation heuristicf solutionf genneighbors openlist Queue.PriorityQueue openlist.put heuristicf formation node formation.. heuristicf solutionf genneighbors openlist Queue.PriorityQueue openlist.put heuristicf formation node formation 0 None closedlist..

Using Python's Multiprocessing module to execute simultaneous and separate SEAWAT/MODFLOW model runs

http://stackoverflow.com/questions/9874042/using-pythons-multiprocessing-module-to-execute-simultaneous-and-separate-seawa

import os subprocess sys import multiprocessing as mp from Queue import Queue from threading import Thread def run f ws real.. sys import multiprocessing as mp from Queue import Queue from threading import Thread def run f ws real f.split '_' 1.. model xsec_a' wdir os.path.join ws r'fieldgen reals' q Queue for f in os.listdir wdir if f.endswith '.npy' q.put_nowait os.path.join..