File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,8 @@ def run(*arguments)
113113
114114 # Run an asynchronous task as a child of the current task.
115115 def async ( *arguments , **options , &block )
116+ raise "Cannot create child task within a task that has finished execution!" if self . finished?
117+
116118 task = Task . new ( self , **options , &block )
117119
118120 task . run ( *arguments )
Original file line number Diff line number Diff line change 1212describe Async ::Task do
1313 let ( :reactor ) { Async ::Reactor . new }
1414
15- describe '.yield' do
15+ with '.yield' do
1616 it "can yield back to scheduler" do
1717 state = nil
1818
142142 end
143143 end . to raise_exception ( SignalException , message : be =~ /TERM/ )
144144 end
145+
146+ it "can't start child task after finishing" do
147+ task = reactor . async do |task |
148+ end
149+
150+ task . wait
151+
152+ expect do
153+ task . async do |task |
154+ end
155+ end . to raise_exception ( RuntimeError , message : be =~ /finished/ )
156+ end
145157 end
146158
147159 with '#yield' do
You can’t perform that action at this time.
0 commit comments