simultaneous

Android simultaneous db operations — “database is locked”

时光总嘲笑我的痴心妄想 提交于 2019-12-01 23:09:48
问题 I'm writing an application with an "online mode", that is, data is downloaded, parsed and inserted into a SQLite database as needed. All this is performed by a service. The app consists of several activities that ask the service for a data update (different data depending on the activity). When the user navigates through the activities (without waiting for the service to finish), it's very easy to get SQLiteExceptions (message: database is locked ). I thought about using synchronized blocks,

Android simultaneous db operations — “database is locked”

霸气de小男生 提交于 2019-12-01 21:50:28
I'm writing an application with an "online mode", that is, data is downloaded, parsed and inserted into a SQLite database as needed. All this is performed by a service. The app consists of several activities that ask the service for a data update (different data depending on the activity). When the user navigates through the activities (without waiting for the service to finish), it's very easy to get SQLiteExceptions (message: database is locked ). I thought about using synchronized blocks, but that would force the user to wait while loading a new activity (that needs database access to load)

Python Multiple users append to the same file at the same time

a 夏天 提交于 2019-11-30 10:58:26
问题 I'm working on a python script that will be accessed via the web, so there will be multiple users trying to append to the same file at the same time. My worry is that this might cause a race condition where if multiple users wrote to the same file at the same time and it just might corrupt the file. For example: #!/usr/bin/env python g = open("/somepath/somefile.txt", "a") new_entry = "foobar" g.write(new_entry) g.close Will I have to use a lockfile for this as this operation looks risky. 回答1

Playing video with AVPlayer and recording sound with AVAudioRecorder simultaneously

六眼飞鱼酱① 提交于 2019-11-30 04:03:57
I was googling this problem for many days but I didn't find a solution for my simple problem. I'm trying to play a video while recording sound. Recording sound works fine without the video. And the video works fine without the recording. As soon as I put both together, the recording throws values which do not react on sound and the video is not playing anymore. By the way this happens only on my device (iPhone 4 / iOS5). In the simulator everything works fine. This is a reduced version of my code which is in a ViewController. // Audio Recorder NSURL *nullUrl = [NSURL fileURLWithPath:@"/dev

Python Multiple users append to the same file at the same time

浪子不回头ぞ 提交于 2019-11-29 22:21:19
I'm working on a python script that will be accessed via the web, so there will be multiple users trying to append to the same file at the same time. My worry is that this might cause a race condition where if multiple users wrote to the same file at the same time and it just might corrupt the file. For example: #!/usr/bin/env python g = open("/somepath/somefile.txt", "a") new_entry = "foobar" g.write(new_entry) g.close Will I have to use a lockfile for this as this operation looks risky. phihag You can use file locking : import fcntl new_entry = "foobar" with open("/somepath/somefile.txt", "a

Simultaneous .replace functionality

[亡魂溺海] 提交于 2019-11-29 10:31:26
I have already converted user input of DNA code (A,T,G,C) into RNA code (A,U,G,C) . This was fairly easy RNA_Code=DNA_Code.replace('T','U') Now the next thing I need to do is convert the RNA_Code into it's compliment strand. This means I need to replace A with U, U with A, G with C and C with G, but all simultaneously. if I say RNA_Code.replace('A','U') RNA_Code.replace('U','A') it converts all the As into Us then all the Us into As but I am left with all As for both. I need it to take something like AUUUGCGGCAAA and convert it to UAAACGCCGUUU . Any ideas on how to get this done?(3.3) Use a

Android: Limit of simultaneous BLE connections

别来无恙 提交于 2019-11-29 07:13:36
we are developing an Android app which can connect to multiple heart rate sensors simultaneoulsy via Bluetooth Low Energy. We have an implementation which is working quite well, so the code is not the problem. What drives us crazy is the limitation of parallel BLE-connections which seems to be different from device to device. We have a few test devices here: Motorola MotoE and MotoG, a Samsung Galaxy Tab A and an HTC Nexus 9. All of them are running Android 5 or 6, original vendor versions. None of them is able to connect to more than 7 BLE HR sensors simultaneously. Then I have tested with my

Parallel HTTP requests in PHP using PECL HTTP classes [Answer: HttpRequestPool class]

自闭症网瘾萝莉.ら 提交于 2019-11-28 21:34:48
The HttpRequestPool class provides a solution. Many thanks to those who pointed this out. A brief tutorial can be found at: http://www.phptutorial.info/?HttpRequestPool-construct Problem I'd like to make concurrent/parallel/simultaneous HTTP requests in PHP. I'd like to avoid consecutive requests as: a set of requests will take too long to complete; the more requests the longer the timeout of one request midway through a set may cause later requests to not be made (if a script has an execution time limit) I have managed to find details for making simultaneuos [sic] HTTP requests in PHP with

Concurrent access to static methods

落爺英雄遲暮 提交于 2019-11-28 20:30:25
I have a static method with the following signature: public static List<ResultObjects> processRequest(RequestObject req){ // process the request object and return the results. } What happens when there are multiple calls made to the above method concurrently? Will the requests be handled concurrently or one after the other? Andremoniy Answering exactly your question: Method will be executed concurrently (multiple times in the same time if you have several threads). Requests will be handled concurrently. You need to add the synchronized modifier if you are working with objects that require

Concurrent access to static methods

百般思念 提交于 2019-11-27 12:18:34
问题 I have a static method with the following signature: public static List<ResultObjects> processRequest(RequestObject req){ // process the request object and return the results. } What happens when there are multiple calls made to the above method concurrently? Will the requests be handled concurrently or one after the other? 回答1: Answering exactly your question: Method will be executed concurrently (multiple times in the same time if you have several threads). Requests will be handled