Questions tagged [asynchronous]

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...

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...

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._...

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...

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...

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...

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...

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...

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...

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...

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...

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...

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...

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...

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...

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....

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://...

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...

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...

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...

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...

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...

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...

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...

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...

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...

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...

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...

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...

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...