queue

Python Multithreading missing data

喜夏-厌秋 提交于 2021-01-29 13:29:11
问题 useI am working on a python script to check if the url is working. The script will write the url and response code to a log file. To speed up the check, I am using threading and queue. The script works well if the number of url's to check is small but when increasing the number of url's to hundreds, some url's just will miss from the log file. Is there anything I need to fix? My script is #!/usr/bin/env python import Queue import threading import urllib2,urllib,sys,cx_Oracle,os import time

ForkingPickler(file, protocol).dump(obj) TypeError: cannot pickle '_tkinter.tkapp' object

百般思念 提交于 2021-01-29 09:20:09
问题 Below is my code my function receives data blocks from the server and puts them in a FIFO buffer after which two functions are called in parallel, recvData() #to keep receiving data blocks from the server and put in the FIFO buffer calculate_threshold() #to remove data blocks from the FIFO buffer and perform some calculation, give a real time display on the GUI, and write the result in the file Code import socket import turtle #import timeit import queue import multiprocessing from tkinter

Implementation of Queue using pointers : segmentation error

自闭症网瘾萝莉.ら 提交于 2021-01-29 09:19:27
问题 I am trying to implement a FIFO. The code compiles without errors but i get segmentation fault when running the program. What is the problem? #include <stdio.h> #include <stdlib.h> struct cell { int element; struct cell *next; }; struct queue { struct cell *front; struct cell *rear; }; void enqueue(int x, struct queue *Q); void dequeue(struct queue *Q); main() /* Manipulation of a linked queue of cells. */ { struct queue *Q; struct cell *q; int i; Q->front=Q->rear=NULL; for(i=0; i<8; i++)

ForkingPickler(file, protocol).dump(obj) TypeError: cannot pickle '_tkinter.tkapp' object

旧巷老猫 提交于 2021-01-29 09:12:47
问题 Below is my code my function receives data blocks from the server and puts them in a FIFO buffer after which two functions are called in parallel, recvData() #to keep receiving data blocks from the server and put in the FIFO buffer calculate_threshold() #to remove data blocks from the FIFO buffer and perform some calculation, give a real time display on the GUI, and write the result in the file Code import socket import turtle #import timeit import queue import multiprocessing from tkinter

Python multiprocessing queue is empty although it is filled in a different thread

删除回忆录丶 提交于 2021-01-28 07:33:04
问题 I have now tried to resolve this issue for multiple hours but no matter what I do, I never get the thing to work. My project tracks live data and provides an endpoint for other services to get the latest(ish) measurement. But no matter what I do, the queue.get() always returns nothing. Here is my code: from collections import deque import numpy as np import argparse import imutils import cv2 from flask import Flask from multiprocessing import Queue import threading import Queue as Q app =

Deadlock with big object in multiprocessing.Queue

笑着哭i 提交于 2021-01-28 04:14:44
问题 When you supply a large-enough object into multiprocessing.Queue , the program seems to hang at weird places. Consider this minimal example: import multiprocessing def dump_dict(queue, size): queue.put({x: x for x in range(size)}) print("Dump finished") if __name__ == '__main__': SIZE = int(1e5) queue = multiprocessing.Queue() process = multiprocessing.Process(target=dump_dict, args=(queue, SIZE)) print("Starting...") process.start() print("Joining...") process.join() print("Done") print(len

What does {error C2338: (boost::has_trivial_destructor<T>::value)} mean for boost::lockfree::queue ? What am I missing here? [duplicate]

雨燕双飞 提交于 2021-01-28 03:25:27
问题 This question already has answers here : /boost/lockfree/queue.hpp: error: static assertion failed: (boost::has_trivial_destructor<T>::value) (3 answers) Closed 7 years ago . I have a struct MyClass inside another class MyOuterClass I am trying to put into a boost::lockfree::queue. My structure looks like below struct MyClass { MyClass() {} MyClass(const string& topic, const string& multicastChannel, const string& netInterface, MyOuterClass::MY_COMMAND_ENUM command, MyOuterClass::CallbackType

Sharing queue between threads running in different modules

旧城冷巷雨未停 提交于 2021-01-28 02:19:29
问题 I have some modules in different packages for my project. This project requires several threads which might be started in different modules, and I intend to use queues for the inter-thread communication. Is there a way to pass a queue created in one module for use in another module? # ModuleA.py myQueue = Queue.Queue() thread = myThread(threadID1, tName1, myQueue) thread2 = myThread(threadID2, tName2, myQueue) # ModuleB.py myQueue = get_the_previous_queue_created() # possible? thread3 =

Implementing Delay Queue using one or more standard FIFO Queues [closed]

女生的网名这么多〃 提交于 2021-01-27 18:41:05
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . A delay queue is a queue in which each message has a delay time associated with it and a message can only be taken when its delay has expired. The head of the queue is that message whose delay expired furthest in

Problem with thread-safe queue?

泪湿孤枕 提交于 2021-01-27 18:26:20
问题 I'm trying to write a thread-safe queue using pthreads in c++. My program works 93% of the time. The other 7% of the time it other spits out garbage, OR seems to fall asleep. I'm wondering if there is some flaw in my queue where a context-switch would break it? // thread-safe queue // inspired by http://msmvps.com/blogs/vandooren/archive/2007/01/05/creating-a-thread-safe-producer-consumer-queue-in-c-without-using-locks.aspx // only works with one producer and one consumer #include <pthread.h>