queue

Sharing many queues among processes in Python

天大地大妈咪最大 提交于 2019-12-17 19:16:27
问题 I am aware of multiprocessing.Manager() and how it can be used to create shared objects, in particular queues which can be shared between workers. There is this question, this question, this question and even one of my own questions. However, I need to define a great many queues, each of which is linking a specific pair of processes. Say that each pair of processes and its linking queue is identified by the variable key . I want to use a dictionary to access my queues when I need to put and

Jquery queueing animations

情到浓时终转凉″ 提交于 2019-12-17 19:01:09
问题 I have several animations that I want to perform on different objects in the dom. I want them to occur in order. I do not want to do it like this: $('#first').show(800, function () { $('#second').show(800, function () {...etc...}); I want to add all my animations(and cpu intensive functions) to some kind of queue object that will make sure they execute sequentially. 回答1: I'm not sure why you don't want to use the method you described. If its purely from an organizational standpoint you don't

How to queue background tasks in ASP.NET Web API

我们两清 提交于 2019-12-17 18:18:58
问题 I have a webapi that is designed to process reports in a queue fashion. The steps the application takes are as follows: Receive content Map the content to an object and place it into the queue Poll for pending items in the queue Process items in queue one at a time I was thinking to use Entity Framework to create a database of queued items, such as: public class EFBatchItem { [Key] public string BatchId { get; set; } public DateTime DateCreated { get; set; } public DateTime DateCompleted {

Creating BackgroundWorker with Queue

匆匆过客 提交于 2019-12-17 16:30:10
问题 I need to create queue and use it with BackgroundWorker. So I can add operations and when one is done next is starting in background. I found this code by google: public class QueuedBackgroundWorker<T> { public void QueueWorkItem( Queue queue, T inputArgument, Func<T> doWork, Action workerCompleted) { if (queue == null) throw new ArgumentNullException("queue"); BackgroundWorker bw = new BackgroundWorker(); bw.WorkerReportsProgress = false; bw.WorkerSupportsCancellation = false; bw.DoWork +=

d3.js v5 - Promise.all replaced d3.queue

徘徊边缘 提交于 2019-12-17 16:28:22
问题 I've been using d3.js v4 for sometime now and I've learned that Mike Bostock has replaced the d3.queue in the v5 release with the Promise native JavaScript object. I would like to check with you if this code that I have written is properly queuing (asynchronously) these URL's: var makeRequest = function() { "use strict"; var bli = [ "http://stats.oecd.org/sdmx-json/data/BLI2013/all/all", "http://stats.oecd.org/sdmx-json/data/BLI2014/all/all", "http://stats.oecd.org/sdmx-json/data/BLI2015/all

How check if a task is already in python Queue?

不问归期 提交于 2019-12-17 15:56:12
问题 I'm writing a simple crawler in Python using the threading and Queue modules. I fetch a page, check links and put them into a queue, when a certain thread has finished processing page, it grabs the next one from the queue. I'm using an array for the pages I've already visited to filter the links I add to the queue, but if there are more than one threads and they get the same links on different pages, they put duplicate links to the queue. So how can I find out whether some url is already in

Python: Writing to a single file with queue while using multiprocessing Pool

五迷三道 提交于 2019-12-17 15:31:05
问题 I have hundreds of thousands of text files that I want to parse in various ways. I want to save the output to a single file without synchronization problems. I have been using multiprocessing pool to do this to save time, but I can't figure out how to combine Pool and Queue. The following code will save the infile name as well as the maximum number of consecutive "x"s in the file. However, I want all processes to save results to the same file, and not to different files as in my example. Any

How do I chain or queue custom functions using JQuery?

让人想犯罪 __ 提交于 2019-12-17 15:30:03
问题 I have multiple functions the do different animations to different parts of the HTML. I would like to chain or queue these functions so they will run the animations sequentially and not at the same time. I am trying to automate multiple events in sequence to look like a user has been clicking on different buttons or links. I could probably do this using callback functions but then I would have to pull all of the animations from the different functions and regroup in the right pattern. Does

LinkedBlockingQueue vs ConcurrentLinkedQueue

佐手、 提交于 2019-12-17 14:59:18
问题 My question relates to this question asked earlier. In situations where I am using a queue for communication between producer and consumer threads would people generally recommend using LinkedBlockingQueue or ConcurrentLinkedQueue ? What are the advantages / disadvantages of using one over the other? The main difference I can see from an API perspective is that a LinkedBlockingQueue can be optionally bounded. 回答1: For a producer/consumer thread, I'm not sure that ConcurrentLinkedQueue is even

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

爱⌒轻易说出口 提交于 2019-12-17 06:11:33
问题 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 def task(args): count = args[0] queue = args[1] for i in xrange(count): queue.put("%d mississippi" % i) return "Done" def main(): q = multiprocessing.Queue()