queue

Queue vs JoinableQueue in Python

Queue vs JoinableQueue in Python Question: In Python while using multiprocessing module there are 2 kinds of queues: Queue JoinableQueue. What is the difference between them? Queue from multiprocessing import Queue q = Queue() q.put(item) # Put an item on the queue item = q.get() # Get an item from the queue JoinableQueue from multiprocessing …

Total answers: 2

How to obtain the results from a pool of threads in python?

How to obtain the results from a pool of threads in python? Question: I have searched here about how to do threading in python, but by far i haven’t been able to get the answer i need. I’m not very familiar with the Queue and Threading python classes and for that reason some of the …

Total answers: 1

Equivalent of asyncio.Queues with worker "threads"

Equivalent of asyncio.Queues with worker "threads" Question: I’m trying to figure out how to port a threaded program to use asyncio. I have a lot of code which synchronizes around a few standard library Queues, basically like this: import queue, random, threading, time q = queue.Queue() def produce(): while True: time.sleep(0.5 + random.random()) # sleep …

Total answers: 3

how to get the queue in which a task was run – celery

how to get the queue in which a task was run – celery Question: I’m new using celery and have a question. I have this simple task: @app.task(name=’test_install_queue’) def test_install_queue(): return subprocess.call(“exit 0″,shell=True) and I am calling this task later in a test case like result = tasks.test_default_queue.apply_async(queue=”install”) The task run successfully in the queue …

Total answers: 3

python multiprocessing – process hangs on join for large queue

python multiprocessing – process hangs on join for large queue Question: I’m running python 2.7.3 and I noticed the following strange behavior. Consider this minimal example: from multiprocessing import Process, Queue def foo(qin, qout): while True: bar = qin.get() if bar is None: break qout.put({‘bar’: bar}) if __name__ == ‘__main__’: import sys qin = Queue() …

Total answers: 4

How to create a delayed queue in RabbitMQ?

How to create a delayed queue in RabbitMQ? Question: What is the easiest way to create a delay (or parking) queue with Python, Pika and RabbitMQ? I have seen an similar questions, but none for Python. I find this an useful idea when designing applications, as it allows us to throttle messages that needs to …

Total answers: 6

examining items in a python Queue

How to get the items in Queue without removing the items in Python? Question: get() removes and returns an item from Queue in Python. import queue q = queue.Queue() # Here q.put("Apple") q.put("Orange") q.put("Banana") print(q.get()) print(q.get()) print(q.get()) Output: Apple Orange Banana Now, I want to get the items in Queue without removing the items. Is …

Total answers: 5

How to clear a multiprocessing.Queue?

How to clear a multiprocessing.Queue? Question: I just want to know how to clear a multiprocessing.Queue like a queue.Queue in Python: >>> import queue >>> queue.Queue().clear() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: ‘Queue’ object has no attribute ‘clear’ >>> queue.Queue().queue.clear() >>> import multiprocessing >>> multiprocessing.Queue().clear() Traceback (most recent call …

Total answers: 5

'Queue' object has no attribute 'size'

'Queue' object has no attribute 'size' Question: I have seen other examples of this happening on StackOverflow, but I didn’t understand any of the answers (I’m still a new programmer,) nor did the other examples I saw look quite like mine, else I wouldn’t post this question. I’m running Python 3.2 on Windows 7. I …

Total answers: 2