Package empro :: Module empro :: Module core :: Class EmSubprocessIpc
[frames] | no frames]

Class EmSubprocessIpc

IPC interface between a parent and a child process (used by both sides)

Class Hierarchy for EmSubprocessIpc
Class Hierarchy for EmSubprocessIpc

Instance Methods
None
abort()
Disconnects immediately; as parent will kill the child process.
bool
askToSpeak()
Tries to stop the peer's event loop, waiting for my message.
None
connectToChild(program, argumentsBeforeSocketName, textBeforeSocketName, argumentsAfterSocketName, workingDirectory)
Starts the child process and sets up a connection.
None
connectToParent(socketName)
Connects to the parent process.
None
disconnect()
Disconnects; if the socket needs to flush its data or the child process still needs to terminate, the status becomes Disconnecting.
None
sendAsyncMessage(asyncMessage)
Sends an unacknowledged message (allowed in Connecting, Connected and ConnectedPeerWaitsListening states).
tuple(string,bool)
speak(message, dialogContinues)
Sends a message to the listening peer and waits for a reply if (dialogContinues).
None
waitUntilDisconnected()
Waits until the status is Disconnected.
tuple(string,bool)
waitUntilSpokenTo()
Blocks until the peer has asked to speak (which will return true) and has spoken something.
None
waitWhileConnecting()
Waits while the status is Connecting.
Properties
list(string)None receivedAsyncMessages
Received asynchronous messages.
stringNone status
The current status {Disconnected,Connecting,Connected,ConnectedPeerWaitsListening,Disconnecting}
Method Details

askToSpeak()

 

Tries to stop the peer's event loop, waiting for my message. Allowed in Connecting and Connected states. Always returns true in the parent; can return false in the child if the parent also asked to speak simultaneously, to avoid deadlock. When true is returned, the status will be ConnectedPeerWaitsListening.

Returns: bool

connectToChild(program, argumentsBeforeSocketName, textBeforeSocketName, argumentsAfterSocketName, workingDirectory)

 

Starts the child process and sets up a connection.

Parameters:
  • program (string) - Path to the program.
  • argumentsBeforeSocketName (list(string)) - Arguments before the socket name.
  • textBeforeSocketName (string) - Initial text before the socket name argument.
  • argumentsAfterSocketName (list(string)) - Arguments after the socket name.
  • workingDirectory (string) - The working directory.
Returns: None

connectToParent(socketName)

 

Connects to the parent process.

Parameters:
  • socketName (string) - The socket name.
Returns: None

sendAsyncMessage(asyncMessage)

 

Sends an unacknowledged message (allowed in Connecting, Connected and ConnectedPeerWaitsListening states).

Parameters:
  • asyncMessage (string) - The message.
Returns: None

speak(message, dialogContinues)

 

Sends a message to the listening peer and waits for a reply if (dialogContinues). Returns the peer's reply and whether to continue the dialog, or the original arguments in case dialogContinues was already False. Allowed in the ConnectedPeerWaitsListening state. The status will remain ConnectedPeerWaitsListening only if dialogContinues was and remains true.

Parameters:
  • message (string) - The message.
  • dialogContinues (bool) - Whether to let the peer continue the dialog.
Returns: tuple(string,bool)

waitUntilSpokenTo()

 

Blocks until the peer has asked to speak (which will return true) and has spoken something. You can also use this when askToSpeak() returned false to pick up the conversation instead of having peerStartedSpeaking() being emitted from the event loop. Returns the peer's reply and whether to continue the dialog. Allowed in Connecting and Connected states. The status will be Connected or ConnectedPeerWaitsListening.

Returns: tuple(string,bool)

Property Details

receivedAsyncMessages

Received asynchronous messages. The user is always responsible to remove any message from the list.

Type:
list(string)None