Questions tagged [co]

The Co javascript library for generator based flow-control of asynchronous tasks

Co is a javascript library for executing generators that yield asynchronous tasks, so that asynchronous code can be written in a more concise manner.

114 questions
0
votes
1 answer

how to use co.wrap with generator

const co = require('co'); const func1 = function(){ setTimeout(()=>{ console.log('func1'); },2000); } const func2 = function(){ setTimeout(()=>{ console.log('func2'); },2000); } const func3 = function(){ …
김다슬
  • 17
  • 5
0
votes
3 answers

How to access super class method inside of internal generator function?

Look at this classes, Base and Derived, it's just simple classes that has "name" as property: class Base { constructor(name) { this.name = name; } printName() { console.log("Base: " + this.name); } } class Derieved…
modernator
  • 3,631
  • 11
  • 38
  • 68
0
votes
0 answers

Yield not pausing generator using co in nodejs with bigquery jobs

co(const levelOneQueries = function*(){ try{ var data = yield getResults(queries.sqlQuery1,queries.dest_sqlQ1); console.log("Level One Query Output",data); } catch(err){ console.log('Error gettinng results',err); …
0
votes
1 answer

Async api request with db request in js mocha?

I build nodejs server, and now I'm testing it with mocha. I have problem with async requests. I send my object to API, and then check record for with object in DB. I need use only co library and generators. There's error: TypeError: Cannot read…
0
votes
1 answer

What does Error: missing 'probdata' mean in OpenMDAO

I'm just get stared at OpenMDAO and multidisciplinary optimization, I'm going to use OpenMDAO to build a CO(Collaborative Optimization) framwork on the classical Sellar problem. However, when I ran this code I always get the following…
Will
  • 81
  • 1
  • 10
0
votes
3 answers

Function returning map before foreach ended

I have this little program that calculates totals by multiplying a rate and some hours. The problem I am having is that the function getTasks() always return an empty map. When I log the fields being entered in the map, they are not empty but they…
horstenwillem
  • 90
  • 2
  • 11
0
votes
0 answers

incorporating co* library into async code

I am confused as to how to use the co package to make my following async code more readable https://www.npmjs.com/package/co async.each(longList, function(address, callback) { googleMapsClient.geocode({ address: address }, function(err,…
Bubble Trouble
  • 499
  • 7
  • 14
0
votes
2 answers

How to execute code while waiting for a promise to finish

I have an express application where I have a generator function that needs aprox. 5 minutes for processing a lot of data. Unfortunately I can not optimize that function. Express automatically times out after 2 minutes and I do not want to alter…
Felix
  • 117
  • 2
  • 12
0
votes
1 answer

Set a sleep interval between each resolve with co?

I'm using co to execute a generator with a bunch of http requests: co(function *(){ // resolve multiple promises in parallel var a = httpRequest(...); var b = httpRequest(...); var c = httpRequest(...); var res = yield [a, b, c]; …
Qian Chen
  • 12,930
  • 14
  • 54
  • 81
0
votes
1 answer

Nodejs Scheduler (Agenda) with co - no callback

I am using Agenda 0.9.0, mongoose 4.7.5, co 4.6.5, for some unknown reason done() is never called in none of the places. The job is timing out and is run every 10 s instead of 2 (if i don't override default 10 minutes, it will run every 10…
gad0lin
  • 101
  • 7
0
votes
0 answers

tomcat different context path of one webapp based on domain

I've got one web application, and I want it to be hosted on two different context paths. There is no problem with that But I want it to be based on domains,…
Rotek
  • 65
  • 9
0
votes
0 answers

Using co with node-mysql2

I am using the co library with node-mysql2. const newActivityCount = co.wrap(function *(memberId) { var sql = "SELECT 1"; var conn = yield pool.getConnection(); var results = yield conn.execute(sql); yield conn.release(); …
runtimeZero
  • 22,318
  • 19
  • 63
  • 115
0
votes
1 answer

How to store Json output value in variable through Ansible

In Ansible,I am using REST API...I want value of clientid from below code and want to use it in another task..I am using ansible uri module. debug: var=clients.json.clientProperties[3].client.clientEntity.clientId when:…
Dipali
  • 1
0
votes
1 answer

Parallelize execution of Promise containing co wrapped generator

I'm creating seed data for my database. The seed function is co-wrapped generator (https://www.npmjs.com/package/co): createSeedData () { co(function * () { [...] } } At one point I'm trying to create 40 auctions with one bid each. Up…
Hedge
  • 13,498
  • 35
  • 122
  • 223
0
votes
1 answer

new object with async routines

I want to instantiate an object where the constructor performs async calls before returning. The purpose is to do async currying. I am using co. The below example fails. What am I doing wrong? var co = require('co') function asyncFunction() {…
Pål Thingbø
  • 1,003
  • 12
  • 16