Skip to content

Instantly share code, notes, and snippets.

@erikdubbelboer
Created March 2, 2012 10:06
Show Gist options
  • Save erikdubbelboer/1957486 to your computer and use it in GitHub Desktop.
Save erikdubbelboer/1957486 to your computer and use it in GitHub Desktop.
nodejs db-mysql blocking call example
var mysql = require('db-mysql');
for (var i = 0; i < 4; ++i) {
new mysql.Database({
hostname: hostname,
user : user,
password: password,
database: database
}).connect(function() {
this.query('SELECT SLEEP(10)').execute(function() {
console.log('slow query is done');
});
});
}
new mysql.Database({
hostname: hostname,
user : user,
password: password,
database: database
}).connect(function() {
this.query('SELECT 1').execute(function() {
console.log('I will only run after the slow selects are done');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment