queue

Python CGI queue

只愿长相守 提交于 2019-12-04 05:04:40
问题 I'm working on a fairly simple CGI with Python. I'm about to put it into Django, etc. The overall setup is pretty standard server side ( i.e. computation is done on the server): User uploads data files and clicks "Run" button Server forks jobs in parallel behind the scenes, using lots of RAM and processor power. ~5-10 minutes later (average use case), the program terminates, having created a file of its output and some .png figure files. Server displays web page with figures and some summary

Can findOne match first or last?

人盡茶涼 提交于 2019-12-04 04:57:02
问题 I'm specifically using mongoose, although I don't believe that matters that much. For example, say I have a collection called MongoQueue and I add a few people to that queue. `MongoQueue.save {function(err, firstPerson) { if (err) console.log(err); MongoQueue.save {function(err, secondPerson) { if (err) console.log(err); MongoQueue.save {function(err, thirdPerson) { if (err) console.log(err); }}}` How do I retrieve the person who was first saved to MongoQueue? Or....how does the findOne()

Strange Queue.PriorityQueue behaviour with multiprocessing in Python 2.7.6

放肆的年华 提交于 2019-12-04 04:48:44
As you know from the title, I'm trying to use PriorityQueue with multiprocessing. More precisely, I wanted to make shared PriorityQueue, wrote some code and it doesn't run as I expected. Look at the code: import time from multiprocessing import Process, Lock from Queue import PriorityQueue def worker(queue): lock = Lock() with lock: for i in range(100): queue.put(i) print "worker", queue.qsize() pr_queue = PriorityQueue() worker_process = Process(target = worker, args = (pr_queue,)) worker_process.start() time.sleep(5) # nope, race condition, you shall not pass (probably) print "main", pr

queue with time stamped elements within a time period

心不动则不痛 提交于 2019-12-04 04:40:46
I want to store in a queue, datastructure does not matter, only the elements that I have inserted within say last 5 minutes from current time. Anything older should get removed - so that any time I get the size of the queue it will give count of the objects inserted in last 5 minutes. Basically all I have to know is how many times my app has made a http call to a sever in last 5 minutes before making the next call. If anyone knows of some existing library that may have this implementation please share. You can use a Priority Queue with timestamps as your keys. So that when you call Peek() you

Python multiprocessing: RuntimeError: “Queue objects should only be shared between processes through inheritance”

你说的曾经没有我的故事 提交于 2019-12-04 03:51:29
问题 I am aware of multiprocessing.Manager() and how it can be used to create shared objects. In particular, queues which can be shared among workers. There is this question, this question, and this question. However, these links don't mention why we can use inheritance for sharing between processes. As I understand, a queue can still only be copied in this case. 回答1: The Queue implementation in python relies on a system pipe to transmit the data from one process to another and some semaphores to

PostgreSQL - implementing a reliable queue

五迷三道 提交于 2019-12-04 03:04:04
问题 I am trying to implement a reliable queue with multiple writers and a multiple readers using postgres database. How to avoid missing rows when a queue reader scans a table then in-progress transactions commit after it reads. We have a reader selecting rows in batches using a “checkpoint” time, where each batch gets the rows after the last timestamp in the previous batch, and we are missing rows. (Reason: The timestamp value is based on the time INSERT happens(00.00.00). At heavy loads, if the

How to Access the printer queue within java

一曲冷凌霜 提交于 2019-12-04 02:13:31
问题 Suppose that I printed some documents from a program like MS Word. Let's say I selected 4 documents at once, so three of them would end up waiting in the printer queue. I would like to access and read some information about the documents waiting in the queue. In other words, how can I access the printer queue and read information about any pending files with java? Is there a way to do that? If so, how can I do it? Thanks for the help 回答1: Here you can find complete code for accessing printer

Difference requiresMainQueueSetup and dispatch_get_main_queue?

喜欢而已 提交于 2019-12-04 01:38:49
I am trying to learn about creating react-native modules for iOS and there is one aspect that came up Official documentation on threading mentions this block of code alongside its variations - (dispatch_queue_t)methodQueue { return dispatch_get_main_queue(); } There is another undocumented peace I saw a lot in the third party libraries which is this + (BOOL)requiresMainQueueSetup { return NO; } To me, these look kinda similar yet different, hence I wanted to ask for an explanation of following questions When should dispatch_get_main_queue be added to the module and what happens if it is

The difference between wait_queue_head and wait_queue in linux kernel

柔情痞子 提交于 2019-12-04 01:37:00
I can find many examples regarding wait_queue_head . It works as a signal, create a wait_queue_head , someone can sleep using it until someother kicks it up. But I can not find a good example of using wait_queue itself, supposedly very related to it. Could someone gives example, or under the hood of them? From Linux Device Drivers : The wait_queue_head_t type is a fairly simple structure, defined in <linux/wait.h> . It contains only a lock variable and a linked list of sleeping processes. The individual data items in the list are of type wait_queue_t , and the list is the generic list defined

Using Multithreaded queue in python the correct way?

落花浮王杯 提交于 2019-12-04 00:49:35
I am trying to use The Queue in python which will be multithreaded. I just wanted to know the approach I am using is correct or not. And if I am doing something redundant or If there is a better approach that I should use. I am trying to get new requests from a table and schedule them using some logic to perform some operation like running a query. So here from the main thread I spawn a separate thread for the queue. if __name__=='__main__': request_queue = SetQueue(maxsize=-1) worker = Thread(target=request_queue.process_queue) worker.setDaemon(True) worker.start() while True: try: #Connect