Create, connect, and block on the Lamson worker.
325202
def main(url, lamson_host, lamson_port, lamson_debug):
    
    try:
        worker = LamsonWorker(url=url,
                              lamson_host=lamson_host,
                              lamson_port=lamson_port,
                              lamson_debug=lamson_debug)
        worker.connect()
        worker.run_forever()
    except KeyboardInterrupt:
        worker.close()
291309
def patch_worker_factory():
    
    def create_worker(self, scheduler, worker_processes, assistant=False):
        worker = luigi.worker.Worker(scheduler=scheduler, worker_processes=worker_processes,
            assistant=assistant, worker_id=os.getenv("LAW_SANDBOX_WORKER_ID"))
        worker._first_task = os.getenv("LAW_SANDBOX_WORKER_TASK")
        return worker

    luigi.interface._WorkerSchedulerFactory.create_worker = create_worker
894179
def create_python_worker(self, func, *args, **kwargs):
        """"""
        worker = PythonWorker(func, args, kwargs)
        self._create_worker(worker)
        return worker
366006
def create_producer(self):
        """"""
        with self.connection_pool.acquire(block=True) as conn:
            yield self.producer(conn)
472030
def create(self, name, **kwargs):
        """"""
        return self._write_op(self._create_nosync, name, **kwargs)
1109910
def block_worker(self, worker_id, reason):
        
        params = {'WorkerId': worker_id, 'Reason': reason}

        return self._process_request('BlockWorker', params)
280446
def _setup(self):
        """"""
        agent_config = CONF.get("AGENT", {})
        self._worker_count = agent_config.get('worker_count')
        self._phys_net_map = agent_config.get(
            'physical_network_vswitch_mappings', [])
        self._local_network_vswitch = agent_config.get(
            'local_network_vswitch')
        self._load_physical_network_mappings(self._phys_net_map)
        self._validate_vswitches()

        self._endpoints.append(self)
        self._event_callback_pairs.extend([
            (self._utils.EVENT_TYPE_CREATE, self._process_added_port_event),
            (self._utils.EVENT_TYPE_DELETE, self._process_removed_port_event)
        ])

        tpool.set_num_threads(self._worker_count)
778520
def _work(self):
        """"""
        server = wsgi.Server(
            name=self._AGENT_BINARY,
            num_threads=CONF.AGENT.worker_count)
        server.start(
            application=_MetadataProxyHandler(),
            port=CONF.bind_port,
            host=CONF.bind_host)
        server.wait()
1321962
function createWorkerProxy(workersOrFunctions, opt_options) {
    var options = {
      // Automatically call the callback after a call if the return value is not
      // undefined.
      autoCallback: false,
      // Catch errors and automatically respond with an error callback. Off by
      // default since it breaks standard behavior.
      catchErrors: false,
      // A list of functions that can be called. This list will be used to make
      // the proxy functions available when Proxy is not supported. Note that
      // this is generally not needed since the worker will also publish its
      // known functions.
      functionNames: [],
      // Call console.time and console.timeEnd for calls sent though the proxy.
      timeCalls: false
    };

    if (opt_options) {
      for (var key in opt_options) {
        if (!(key in options)) continue;
        options[key] = opt_options[key];
      }
    }
    Object.freeze(options);

    // Ensure that we have an array of workers (even if only using one worker).
    if (typeof Worker != 'undefined' && (workersOrFunctions instanceof Worker)) {
      workersOrFunctions = [workersOrFunctions];
    }

    if (Array.isArray(workersOrFunctions)) {
      return sendCallsToWorker(workersOrFunctions, options);
    } else {
      receiveCallsFromOwner(workersOrFunctions, options);
    }
  }
73684
function startWorker(port) {
        var worker = child.fork(serverWorker, [
            '--port', port,
            '--server', serverFile,
            '--allowForcedExit', allowForcedExit,
            '--config', JSON.stringify(config.app || {}),
            '--title', workerTitle
        ]);

        worker.on('exit', createWorkerExitHandler(port));
        return worker;
    }
76569
def _link(self, next_worker, next_is_first=False):
        """"""

        lock = multiprocessing.Lock()
        next_worker._lock_prev_input = lock
        self._lock_next_input = lock
        lock.acquire()

        lock = multiprocessing.Lock()
        next_worker._lock_prev_output = lock
        self._lock_next_output = lock
        lock.acquire()

        # If the next worker is the first one, trigger it now.
        if next_is_first:
            self._lock_next_input.release()
            self._lock_next_output.release()
1266489
def start(self):
        """"""
        if (self.cf.link is not None):
            if (self._added is False):
                self.create()
                logger.debug('First time block is started, add block')
            else:
                logger.debug('Block already registered, starting logging'
                             ' for id=%d', self.id)
                pk = CRTPPacket()
                pk.set_header(5, CHAN_SETTINGS)
                pk.data = (CMD_START_LOGGING, self.id, self.period)
                self.cf.send_packet(pk, expected_reply=(
                    CMD_START_LOGGING, self.id))
1344375
function startBlock() {
            blockStack.push({
                let: { initialized: false, uninitialized: false },
                const: { initialized: false, uninitialized: false }
            });
        }
721101
def connect_or_create(self, overwrite=False):
        
        connection = self._get_connection()
        if connection:
            return connection
        else:
            return self.create(overwrite=overwrite)
1101645
def create_consumer(self):
        """"""
        with self.connection_pool.acquire(block=True) as conn:
            yield self.consumer(conn)
801092
def join(self, timeout=None, raise_error=False):
        """"""
        self._workers.join(timeout, raise_error)
1092922
def create(self, name_or_class, mask, filepath=None, **kwargs):
        """"""
        if isinstance(name_or_class, type):
            name = name_or_class.type
            protocol = name_or_class
        else:
            name = name_or_class
            protocol = self.protocols[name]
        assert name in DCC_TYPES
        if filepath:
            kwargs.setdefault('limit_rate',
                              self.config['send_limit_rate'])
            kwargs['filepath'] = filepath
            if protocol.type == DCCSend.type:
                kwargs.setdefault('offset', 0)
                kwargs.update(
                    filename_safe=slugify(os.path.basename(filepath)),
                    filesize=os.path.getsize(filepath),
                )
            elif protocol.type == DCCGet.type:
                try:
                    offset = os.path.getsize(filepath)
                except OSError:
                    offset = 0
                kwargs.setdefault('offset', offset)
                kwargs.setdefault('resume', False)
        kwargs.setdefault('port', None)
        f = protocol(
            mask=mask, ip=int(self.bot.ip),
            bot=self.bot, loop=self.loop, **kwargs)

        if kwargs['port']:
            if self.bot.config.get('dcc_sock_factory'):
                sock_factory = maybedotted(self.bot.config.dcc_sock_factory)
                args = dict(sock=sock_factory(self.bot, f.host, f.port))
            else:
                args = dict(host=f.host, port=f.port)
            task = self.bot.create_task(
                self.loop.create_connection(f.factory, **args))
            task.add_done_callback(partial(self.created, f))
        else:
            task = self.bot.create_task(
                self.loop.create_server(
                    f.factory, '0.0.0.0', 0, backlog=1))
            task.add_done_callback(partial(self.created, f))
        return f