Questions tagged [asynchronous]

12686 questions
0

votes
0

answer
4

Views

An AsyncDuplicateLock that can be locked on all keys

I need a lock similar to the one from this answer from Stephen Cleary: https://stackoverflow.com/a/31194647/4381408 However, I also need to be able to lock on all keys at the same time. I'm using Stephen Cleary's AsyncEx library as well, so I thought of combining the AsyncDuplicateLock with an Async...
t.baart
0

votes
3

answer
40

Views

How to break chain in promise

I'm trying to limit the number of apis fetches in my project by saving them in a simple cache, key collection in mongodb. Is thera way to stop propagation of .then() inside Promise, without using async/await? export const getData = (url: string) => { return new Promise((resolve, reject) => { findInC...
Zeppe
0

votes
0

answer
11

Views

Multiprocessing Queue not timing out Python

I'm working on a networking project and I'm using the multiprocessing Queue to buffer packets before being processed. I want to exit if no more packets are received after some time. This is the function that reads from the queue: def run(self): '''Polls for messages.''' timeout = 10 while not self._...
Jordan Mackie
0

votes
0

answer
4

Views

Clear cache of APM-form

I had created APM page with apm-form element. The form is working perfectly fine on my server and local env. However, when I access website form AMP url I can't send anything. In my console I getting this error: Access to fetch at 'https://example.co.uk/form.php?_gl=....GSg..&__amp_source_origin=htt...
fatycow
1

votes
0

answer
6

Views

parser amp-selector value to php

How can I get the value of the amp selector and save it in a php variable 1 1 1 I tried multiple ways like domdocument but nothing seems to work. Any help would be appreciated $dom = new DOMDocument(); $dom->loadHTML($html); //$num = ''; $optionTags = $dom->getElementsByTagName('div'); print_r($opt...
Ahmad Zreegat
1

votes
4

answer
558

Views

Unit testing Promise task in grails

How do we unit test logic in Promises.task? task{service.method()} I want to validate invocation of the service method inside the task. Is this possible? If yes, how? I read in the documentation that in unit testing async processes, one can use this: Promises.promiseFactory = new SynchronousPromise...
froi
1

votes
2

answer
484

Views

Run a number of groups of QProcess' after each other

I need to call an external program N number of times. I'd like to do this in parallel. So my strategy thus far has been to start N QProcesses and keep a count of ones that have started and ones that have finished. (So I can figure out when they have all finished). However, the external program takes...
jramm
1

votes
1

answer
1.6k

Views

AsyncTask vs Activity.runOnUiThread() vs Handler.post()

I'm studying the code of a large app. There are 3 asynchrony patterns used in the UI, all of them seem equivalent: Pattern 1, AsyncTask new AsyncTask() { protected Boolean doInBackground(X... params) { //background task } protected void onPostExecute(Z res) { //UI callback } }.execute(...
Desik
0

votes
1

answer
30

Views

Promise.all always returns an empty array

I'm trying to solve this promise puzzle and I've had 2 questions: A) I'm wondering why it's returning empty array. What am i doing wrong? B) How can I implement async reduce? B) How can I make it return a Async Array instead of empty array? Note: Please make use of .get method to iterate through th...
TechnoCorner
1

votes
1

answer
25

Views

Is there a way to have a function call itself without re-specifying all its arguments?

If anyone can think of another way to achieve what I'm trying to do, your thoughts are welcome! To give you an idea, I have over 40 different functions that have signatures similar to these: func getXFromServer(arg1: String, arg2: Int, arg3: Bool, completion: ((MyCustomResponse)->Void)? = nil) func...
1

votes
0

answer
19

Views

is there a probability of thread unsafety in javascript?

let arr = [2, 3] let promiseA = new Promise((resolve)=>{ // await for io resolve(arr.shift()) }) let promiseB = new Promise((resolve)=>{ // await for io resolve(arr.shift()) }) let handler = (data)=>{ if(!data){ return console.log('no more') } console.log(data) } promiseA.then(handler...
zzzgoo
-2

votes
2

answer
14

Views

How to use Async in C sharp for loading file

I am not sure if there's any question about these code. which one is a better way? case 1: {GenericLoad newload = new GenericLoad(); Task task1 = GenericFileLoadAsync(CSVFile1, ','); Task task2 = GenericFileLoadAsync(CSVFile2, '|'); task1.Wait(); task2.Wait(); PrintCSV(task1.Result); PrintCSV(task2....
Raj
1

votes
1

answer
527

Views

KeyError: kafka.producer.record_accumulator.RecordBatch

Using kafka-python api to send a bunch of messages to a topic. A portion of messages get successfully sent to the topic but not all of them are sent before the program terminates with the following error message: KeyError: Batch is already closed -- ignoring batch.done() Error processing errback Tr...
r2d2oid
1

votes
4

answer
1.6k

Views

Angular Custom Async Validator stays in pending state

I have a Custom Validator that validates if a user's email is unique or not. I've searched for related topic on stackoverflow and internet, but no help when I'm giving input in the form (sending the request), the request stays at pending state and doesnot resolves. I've tested the backend in postman...
Himanshu Mittal
1

votes
2

answer
249

Views

Recursive Promise-based directory reading

I have a library that scans a directory for files on a remote server. It returns a Promise like this: client.scanRemoteDirectory(path) .then(files => { console.log(files) }) I'm trying to write a recursive method to scan directories and subdirectories too. But I'm running into some async issues. My...
Jake Wilson
1

votes
2

answer
349

Views

Javascript async function is waiting for response without await

I am new to the concept of JavaScript's asynchronous behavior. The below code is confusing me. According to my concept function b should return before the wait function finishes executing because I am not telling it wait using 'await'. But the output I am getting is this : before then it waits for...
Ani
1

votes
4

answer
70

Views

Using Async/Await to call Async functions to assign values to keys in objects [duplicate]

This question already has an answer here: How to use Promise.all with an object as input 8 answers I am wondering how to assign values to multiple different keys asynchronously with Await/Async. Initially I had imagined merely calling the Async function would assign the values such as below: const...
Saga
1

votes
4

answer
39

Views

Chain promises calls

I need a consecutive execution of these three return App.initAccount().then(App.bindEvents).then(App.render); whereas App.initAccount(): initAccount: async function() { console.log('Initializing account...'); await web3.eth.getCoinbase(function(err, account) { if (err !== null) { throw err; } App.ac...
Joseph Kirtman
1

votes
1

answer
70

Views

Async/Await result is empty after await execution

I have a simple function: var result = ''; var url = 'http://someurl.com/?action=perform-action'; (async function() { let a = await fetch(url) result = await a.text(); })() console.log(result) I'm trying to put the result into variable but it returns nothing. My function simply checks if an email en...
Benzine
1

votes
2

answer
71

Views

Split array into chunks/bulks and made operations with them one by one

I'm a bit sorry about tags, probably I understood my problem not right and used them wrong but.. The problem I'm faced with my project is new for me and I never before experienced it. So in my case I have a huge dataset response from DB (Mongo, 100'000+ docs) and I needed to http-request every speci...
AlexZeDim
1

votes
1

answer
1.1k

Views

Exceptions in System.Runtime.CompilerServices.AsyncServices without my code in stack trace

Some of the users of my application experience strange crashes from different exceptions in System.Runtime.CompilerServices.AsyncServices There is none of my code in the stack trace and I don't have a clue where to search for a cause or how to add additional logging to find the reason of the crash....
mephisto123
1

votes
2

answer
1.3k

Views

multiprocessing.apply_async(myfunc, …) within a class doesn't seem to call myfunc

import multiprocessing class multiprocessing_issue: def __init__(self): self.test_mp() def print_test(self): print 'TEST TEST TEST' def test_mp(self): p = multiprocessing.Pool(processes=4) p.apply_async(self.print_test, args=()) print 'finished' if __name__ == '__main__': multiprocessing_issue() I'v...
David Parks
0

votes
0

answer
29

Views

Stop async compressing c#

I start doing async compressing of files by press the button string[] files = Directory.GetFiles(dirName); Task[] tasks = new Task[files.Length]; for (int i = 0; i < tasks.Length; i++) { string sourceFile = files[i]; tasks[i] = new Task(async () => await Compress(sourceFile, $'{sourceFile}z')); } fo...
Giacomo
1

votes
2

answer
156

Views

async API call inside forEach loop

I ran into a problem that I cannot seem to solve, I'm guessing I'm missing some points in terms of async behaviour. The task is relatively simple: A wallet with money in different currencies needs to be transformed into a single currency. I want to get the exchange rate from following API: https://...
Manuel Hong
0

votes
2

answer
19

Views

Return Observable within Async Function

I'm having trouble with the data I get from the server. I need to check if a username is available and then execute an http.get which is no problem, thing is I need to return the content of the http.get as an observable to create an object later. registerUser(user: RegisterComponent): Observable { l...
Antonio Gonzalez
1

votes
1

answer
1.1k

Views

Using async/await syntax with Twisted callbacks

I'd like to use async/await syntax with Twisted Deferred.addCallback method. But as stated in the documentation, addCallback callback is called synchronously. I've seen inlineCallbacks decorator used for this purpose, but I'd prefer using async/await syntax (if it's even possible, or meaningful). I...
user1527491
1

votes
1

answer
48

Views

Task.Wait() on async method works locally, but not via another method

I recently resolved a problem I had while trying to execute an async method. To me, this posed more questions than it solved. In short, I am happy that it works, but I don't know why it does. I was attempting to run the following method of the Microsoft Graph Client library: _graphServiceClient.User...
Johan Wintgens
1

votes
2

answer
649

Views

How can I test async callbacks in JMeter?

I am using WebHooks in my API. So, once a request is processed our REST Service will POST a response back to the callback URL sent in the request. Client Server |(request) | |----------------->| |
Dominic Cabral
1

votes
2

answer
808

Views

.NETCore PostgreSQL “A command is already in progress”

I am developing a WebAPI on .NETCore accessing data to a POSTGRESQL DB. I have troubles with the non-MARS support of PostgreSQL. NPGSQL is unable to support multiple connections from the same instance (as described in EntityFramework DbContext lifecycle + Postgres: 'An operation is already in progr...
fredczj
1

votes
1

answer
232

Views

ASP.NET Core, overkilling Task.Run()?

Lets say we have an ASP.NET Core receiving a string as a payload, size order of couple of megabytes. First method implementation: [HttpPost('updateinfos')] public async Task UpdateInfos() { var len = (int)this.Request.ContentLength; byte[] b = new byte[len]; await this.Request.Body.ReadAsync(b,0,len...
Felice Pollano
1

votes
1

answer
756

Views

Is there anything wrong with my method for calling NHibernate in async?

I am trying to implement Identity's IUserStore with NHibernate, which lacks the async methods required by IUserStore. This is my ignorant attempt at dispatching the blocking call and making the method async: public class QsaasUserStore : IUserStore where TLogin : QsaasUserLogin { public Task CreateA...
ProfK
1

votes
2

answer
155

Views

Django concurrency with celery

I am using django framework and ran into some performance problems. There is a very heavy (which costs about 2 seconds) in my views.py. And let's call it heavy(). The client uses ajax to send a request, which is routed to heavy(), and waits for a json response. The bad thing is that, I think heav...
harold3sigma
1

votes
1

answer
378

Views

C++ boost::asio how to properly use std::shared_ptr on async functions

This is my first project with boost::asio and I´m building an async server. I need to use a shared_ptr to control access to the session control pointer. Here is the way I´m doing to define the session and pass it to the boost async function: // Define the new session object std::shared_ptr session...
Mendes
1

votes
1

answer
187

Views

Understanding Twisted and async programming. Why is a code working and another one is not?

Sorry first the wall of text. I am struggling to understand Twisted and async programming in general. I am using Python 2.7 with Twisted 15.4.0. I tried this example for downloadPage() and it works perfectly. I tinkered a bit with it, changing the callbacks from lambdas to proper functions. It worke...
RandomGuyqwert
1

votes
1

answer
52

Views

My AsyncTask not getting cancelled android

I am working on a task that calls my AsyncTask , once the async task is executed , I wait for 20 seconds to get the data from server , if it is still loading I am cancelling it (handling timeout) public void handleServerTimeOut() { getStore = new GetStore(); getStore.execute(); new Handler().postDel...
karthik kolanji
1

votes
2

answer
1.5k

Views

Java async MySQL queries

First of all, I don't have much experience with thread safe programming. I have a MySQL class, and I want to use one instance in multiple threads to prevent blocking code in the main thread. I read about connection pooling but I want to keep it as simple as it is. This is my MySQL class: package com...
stonar96
1

votes
1

answer
77

Views

How is execution queue generated in JavaScript?

Consider this simple example: console.log('Start'); setTimeout(function() { console.log('First timeout'); }, 100); setTimeout(function () { console.log('Second timeout'); }, 2000); var time = Date.now(); for (var i = 0; i < 2000000000; i++) { var temp = i * i * Math.sqrt(i); temp = temp + temp; } co...
Georgy
1

votes
1

answer
268

Views

Java Google datastore async calls

I do not want to block threads in my application and so I am wondering are calls to the the Google Datastore async? For example the docs show something like this to retrieve an entity: // Key employeeKey = ...; LookupRequest request = LookupRequest.newBuilder().addKey(employeeKey).build(); LookupRes...
user2924127
1

votes
2

answer
39

Views

cannot understand what callback does in a Connect module

I am reading a book about NodeJs Connect. There is this small part about basicAuth module. I know that basicAuth is now deprecated, but I cannot understand this simple code. The book says Providing an asynchronous callback function The final option is similar, except this time a callback is passed...
slevin
1

votes
1

answer
33

Views

Is there any situation where it is impossible to use a Promise and a Deferred must be used? [duplicate]

This question already has an answer here: When would someone need to create a deferred? 2 answers I understand on stylistic/clarity grounds that people may prefer one approach over the other but I'm trying to understand if there is any situation that you can not use a Promise and must use a Deferre...
AJP

View additional questions