When you call a synchronous function on the Meteor server, does it block the entire server until the callback is received?

queueTask = function(callback) { ... }
queueTaskSync = Meteor._wrapAsync(queueTask)
queueTaskSync(function(results) {
    console.log('callback returns after 10 seconds')
    Results.insert(results)
})

In other words, if the callback takes 10 seconds to return, does this mean the server cannot do anything else for 10 seconds?

有帮助吗?

解决方案

It depends where this code is. If the code is in a Meteor.methods on the server additional calls to meteor from the same client will be blocked, but other's wouldn't be blocked since they are in different fibers.

You can bypass this using this.unblock() in your method to make sure the next method calls are run in new fibers, thus making them more concurrent-like.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top