Skip to content

Better IPC needed #3

@ztane

Description

@ztane

In order to really take use of the active mode / cluster mode / whatever, it should be possible to connect via socket to another host, and to a pre-spawned vw process. Currently this is impossible without fully forking the wabbit_wappa code.

That is, ActiveVWProcess currently has an initializer

def __init__(self, command, port=DEFAULT_PORT):
    """'command' is assumed to have the necessary options for use with this
    class, which should be guaranteed in the calling context."""
    # Launch the VW process, which we will communicate with only
    # via its socket
    self.vw_process = pexpect.spawn(command)
    self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    connection_tries = 0
    while connection_tries < MAX_CONNECTION_ATTEMPTS:
        try:
            self.sock.connect(('127.0.0.1', port))
            break  # Quit this loop once successful
        except socket.error:
            connection_tries += 1
            time.sleep(CONNECTION_WAIT)
    self.before = None

Which has at least 3 problems:

  • it uses pexpect to spawn a process whose input is not read
  • it always needs to spawn a new process
  • it hardcodes '127.0.0.1' as the target address

The best solution could be to refactor the VW class to use way more functions, and use the factory pattern for creating the vw_process.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions