queue

Problem with using Semaphore to protect queue

拥有回忆 提交于 2019-12-11 06:01:07
问题 I am using following code to limit use of resources. Once in a while(after 3-4 days of successful run) I get queue empty exception or the returned object is found to be null. I am wondering if I am limiting only 5 threads to enter this Get method, how come this happens. The places where GetConnection is called, ReleaseConnection is also definitely called within the Finally block. With each call, I am also logging no. of resources in the queue. The queue count never seems to be going more than

AFNetworking QUEUE with pdf, png, mp4 files

依然范特西╮ 提交于 2019-12-11 05:42:07
问题 I have a server and i get that response : {"products": [ { "product_id": "1170", "name": "zzzz®", "sort_order": 0, "brand": "zzzas", "product_category_id": "1090", "location_ids": [ "1078" ], "icon_url": "http://zzzzz.com/media/2502/zzzz.png", "icon_date": "Wed, 07 Nov 2012 14:03:47 GMT", "thumbnail_url": "http://zzzz.com/media/2591/zzdfs.png", "thumbnail_date": "Wed, 07 Nov 2012 14:04:02 GMT" }, { "product_id": "1126", "name": "ddddd®", "sort_order": 1, "brand": "dddsas", "product_category

Queued Laravel queued job runs twice after upgrading to Laravel 5.4

自闭症网瘾萝莉.ら 提交于 2019-12-11 05:32:11
问题 We used to run Laravel 5.2, and for one of our processing tasks, we'd run a console command to queue up a job into a Redis queue. Prior to the Laravel 5.4 upgrade, this job would queue up and would get picked up by a queue daemon and would only run once. After the upgrade, however, the job gets picked up twice, about 1 minute apart. There have been zero devops changes so I am trying to figure out what Laravel is doing differently. I can also verify that the console command only queues up the

Advice on implementing put() function in a c++ templated queue?

强颜欢笑 提交于 2019-12-11 05:25:15
问题 I'm trying to implement a queue where I'm not allowed to change the header file definition, which looks like this: class PQueue { private: struct Node { EType Item; unsigned Priority; unsigned Identifier; Node * Pred; Node * Succ; }; Node * Head; // Pointer to head of chain (front) Node * Tail; // Pointer to tail of chain (back) public: // Initialize pqueue to empty // PQueue(); // De-initialize pqueue // ~PQueue(); // Re-initialize pqueue to empty // void reset(); // Initialize pqueue using

Py Queue library - mapping array to queue - py3 issues

醉酒当歌 提交于 2019-12-11 04:52:42
问题 I previously posted a question regarding a script which performed conccurent requests. This script was failing, because of an empty queue. I further investigated the problem and came with this simple problem. We have a function which creates a queue based on an array. We then iterate over the queue, printing the value, until the queue is empty. try: from queue import Queue except: pass try: from Queue import Queue except: pass def test(): q = Queue() a = [1,2,3] map(q.put, a) print("queue

iTunes song queue

被刻印的时光 ゝ 提交于 2019-12-11 04:37:11
问题 My app is controlling iTunes via scripting bridge. Other apps are able to choose a range of songs, and play them in order without having to create a playlist. I have searched the web for examples and red the iTunes.h file a dozen times, but I didn't find a solution. Can maybe someone of you help me? Look at the iTunes header file here: iTunes.h Thanks! 回答1: With iTunes 10 it's simply not possible without creating a playlist. The function(which is a known from great other music players) you

How to inherit from a multiprocessing queue?

你离开我真会死。 提交于 2019-12-11 04:36:47
问题 With the following code, it seems that the queue instance passed to the worker isn't initialized: from multiprocessing import Process from multiprocessing.queues import Queue class MyQueue(Queue): def __init__(self, name): Queue.__init__(self) self.name = name def worker(queue): print queue.name if __name__ == "__main__": queue = MyQueue("My Queue") p = Process(target=worker, args=(queue,)) p.start() p.join() This throws: ... line 14, in worker print queue.name AttributeError: 'MyQueue'

Python Asyncio queue get doesn't receive the message

谁说我不能喝 提交于 2019-12-11 04:29:03
问题 I post a new question related the old for a problem with the get from queue. This is the code (thanks to Martijn Pieters) import asyncio import sys import json import os import websockets async def socket_consumer(socket, outgoing): # take messages from the web socket and push them into the queue async for message in socket: await outgoing.put(message) file = open(r"/home/host/Desktop/FromSocket.txt", "a") file.write("From socket: " + ascii(message) + "\n") file.close() async def socket

Convert queue into long array?

白昼怎懂夜的黑 提交于 2019-12-11 04:24:52
问题 I have a Queue which I want to convert into long[] and pass it to my method which calculate percentiles. private final ConcurrentLinkedQueue<Long> holder = new ConcurrentLinkedQueue<>(); I am using ConcurrentLinkedQueue because I am inserting latencies which are in milliseconds from multithread application into my above holder queue so I wanted to be thread safe. Now my question is how can I convert holder queue into long[] long array so that I can pass it to my below method? Is there any way

Queue implementation, enqueue method not working

主宰稳场 提交于 2019-12-11 04:09:05
问题 I am trying to write my own queue class. My enqueue method is only enqueue-ing one object and then if I try to enqueue anything else, its almost as if its ignoring it. Here is my code: public class myQueue { private Node front; private Node back; private int s; public myQueue() { front = null; back = null; s = 0; } public void enqueue(Object x) { if( isEmpty() ) back = front = new Node(x); else back = back.next = new Node(x); s++; } public Object dequeue() { Object x; if( isEmpty() ) { System