concurrency

Can I call a thread recurrently from within a thread?

与世无争的帅哥 提交于 2021-02-11 08:11:00
问题 I'm trying to transfer samples from thread A ("Acquisition") to thread B ("P300") using queue but I can't read any data in thread B, although samples are being allocated in thread A. Judging by my output, I think my thread B is rushing and testing things before my thread A starts to put data in. See an approximation of my code structure bellow: import threading import queue from queue import Empty import numpy as np import warnings warnings.filterwarnings("error") class AcqThread(threading

Can I call a thread recurrently from within a thread?

核能气质少年 提交于 2021-02-11 08:10:16
问题 I'm trying to transfer samples from thread A ("Acquisition") to thread B ("P300") using queue but I can't read any data in thread B, although samples are being allocated in thread A. Judging by my output, I think my thread B is rushing and testing things before my thread A starts to put data in. See an approximation of my code structure bellow: import threading import queue from queue import Empty import numpy as np import warnings warnings.filterwarnings("error") class AcqThread(threading

Making around 20 HTTP calls and passing data to the database using Java

試著忘記壹切 提交于 2021-02-11 07:07:08
问题 I have a collection of 20 items, I will create a loop for the items and make API Calls to get the data, based on the data returned, I will have to update in the database. This requirement is simple and I am able to accomplish in plain Java. Now for performance, I am learning about using RxJava . I went through many articles in the internet and found that people refer to the async-http-client library for async http calls, I find that the library is out of date and the maintainer is planning

Making around 20 HTTP calls and passing data to the database using Java

久未见 提交于 2021-02-11 07:03:24
问题 I have a collection of 20 items, I will create a loop for the items and make API Calls to get the data, based on the data returned, I will have to update in the database. This requirement is simple and I am able to accomplish in plain Java. Now for performance, I am learning about using RxJava . I went through many articles in the internet and found that people refer to the async-http-client library for async http calls, I find that the library is out of date and the maintainer is planning

MongoDB concurrent update to same document is not behaving atomic

无人久伴 提交于 2021-02-11 06:55:31
问题 Currently, we have an orderId for which we give the benefit(posting) to the user. There are multiple events that can trigger benefit/posting. But the condition is that only 1 event should be triggered. Hence for handling current requests, we created a boolean field POSTING_EVENT_SENT , initially set to false, and later whoever was able to mark it as true can proceed further. public boolean isOrderLockedAndUpdatedToTriggerPosting(String orderId, OrderStatus orderStatus) { Query query = new

MongoDB concurrent update to same document is not behaving atomic

筅森魡賤 提交于 2021-02-11 06:54:09
问题 Currently, we have an orderId for which we give the benefit(posting) to the user. There are multiple events that can trigger benefit/posting. But the condition is that only 1 event should be triggered. Hence for handling current requests, we created a boolean field POSTING_EVENT_SENT , initially set to false, and later whoever was able to mark it as true can proceed further. public boolean isOrderLockedAndUpdatedToTriggerPosting(String orderId, OrderStatus orderStatus) { Query query = new

Problems with race conditions on ConcurrentHashMap

◇◆丶佛笑我妖孽 提交于 2021-02-10 23:54:04
问题 I got a multithreaded application in which n threads write to an ConcurrentHashMap . Another n Threads read from that Map and copy its Value to a copy List. After that the original List is removed from the map. For some reason I always get a ConcurrentModificationException . I even tried to create my own lock mechanism with a volatile boolean, but it won't work. When using Google Guava with Lists.newLinkedList() i get a ConcurrentModificationException . When using the StandardWay new

Problems with race conditions on ConcurrentHashMap

ⅰ亾dé卋堺 提交于 2021-02-10 23:48:27
问题 I got a multithreaded application in which n threads write to an ConcurrentHashMap . Another n Threads read from that Map and copy its Value to a copy List. After that the original List is removed from the map. For some reason I always get a ConcurrentModificationException . I even tried to create my own lock mechanism with a volatile boolean, but it won't work. When using Google Guava with Lists.newLinkedList() i get a ConcurrentModificationException . When using the StandardWay new

Problems with race conditions on ConcurrentHashMap

自古美人都是妖i 提交于 2021-02-10 23:47:45
问题 I got a multithreaded application in which n threads write to an ConcurrentHashMap . Another n Threads read from that Map and copy its Value to a copy List. After that the original List is removed from the map. For some reason I always get a ConcurrentModificationException . I even tried to create my own lock mechanism with a volatile boolean, but it won't work. When using Google Guava with Lists.newLinkedList() i get a ConcurrentModificationException . When using the StandardWay new

Downloading files in chunks in python?

て烟熏妆下的殇ゞ 提交于 2021-02-10 21:42:43
问题 I am writing a simple synchronous download manager which downloads a video file in 10 sections. I am using requests to get content-length from headers. Using this I am breaking and downloading files in 10; byte chunks and then merging them to form a complete video. The code below suppose to work this way but the end merged file only works for seconds and after that it gets corrupted. What is wrong in my code? import requests import os def intervals(parts, duration): part_duration = duration /