Class: Modal::ContainerProcess
- Inherits:
-
Object
- Object
- Modal::ContainerProcess
- Defined in:
- lib/modal/sandbox.rb
Instance Attribute Summary collapse
-
#exec_id ⇒ Object
readonly
Returns the value of attribute exec_id.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdin ⇒ Object
readonly
Returns the value of attribute stdin.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(exec_id, mode) ⇒ ContainerProcess
constructor
A new instance of ContainerProcess.
- #wait ⇒ Object
Constructor Details
#initialize(exec_id, mode) ⇒ ContainerProcess
Returns a new instance of ContainerProcess.
141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/modal/sandbox.rb', line 141 def initialize(exec_id, mode) @exec_id = exec_id @stdin = ModalWriteStream.new(ContainerProcessInputStream.new(exec_id)) if mode == "text" @stdout = ModalReadStream.new(ContainerProcessOutputStream.new(exec_id, Modal::Client::FileDescriptor::FILE_DESCRIPTOR_STDOUT, true)) @stderr = ModalReadStream.new(ContainerProcessOutputStream.new(exec_id, Modal::Client::FileDescriptor::FILE_DESCRIPTOR_STDERR, true)) else @stdout = ModalReadStream.new(ContainerProcessOutputStream.new(exec_id, Modal::Client::FileDescriptor::FILE_DESCRIPTOR_STDOUT, false)) @stderr = ModalReadStream.new(ContainerProcessOutputStream.new(exec_id, Modal::Client::FileDescriptor::FILE_DESCRIPTOR_STDERR, false)) end end |
Instance Attribute Details
#exec_id ⇒ Object (readonly)
Returns the value of attribute exec_id.
139 140 141 |
# File 'lib/modal/sandbox.rb', line 139 def exec_id @exec_id end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
139 140 141 |
# File 'lib/modal/sandbox.rb', line 139 def stderr @stderr end |
#stdin ⇒ Object (readonly)
Returns the value of attribute stdin.
139 140 141 |
# File 'lib/modal/sandbox.rb', line 139 def stdin @stdin end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
139 140 141 |
# File 'lib/modal/sandbox.rb', line 139 def stdout @stdout end |
Instance Method Details
#wait ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/modal/sandbox.rb', line 154 def wait loop do request = Modal::Client::ContainerExecWaitRequest.new( exec_id: @exec_id, timeout: 55 # seconds ) resp = Modal.client.call(:container_exec_wait, request) if resp.completed return resp.exit_code || 0 end sleep(1) # Poll every second end end |