class Async::Reactor
def self.run(*args, **options, &block)
the block as an asynchronous task. Will block until the reactor finishes
- When invoked at the top level, will create and run a reactor, and invoke
asynchronously. Will return the task once it has been scheduled.
- When invoked within an existing reactor task, it will run the given block
The preferred method to invoke asynchronous behavior at the top level.
def self.run(*args, **options, &block) if current = Task.current? reactor = current.reactor return reactor.async(*args, **options, &block) else reactor = self.new(**options) begin return reactor.run(*args, &block) ensure reactor.close end end end