File tree 2 files changed +15
-1
lines changed 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,8 @@ def run(*arguments)
113
113
114
114
# Run an asynchronous task as a child of the current task.
115
115
def async ( *arguments , **options , &block )
116
+ raise "Cannot create child task within a task that has finished execution!" if self . finished?
117
+
116
118
task = Task . new ( self , **options , &block )
117
119
118
120
task . run ( *arguments )
Original file line number Diff line number Diff line change 12
12
describe Async ::Task do
13
13
let ( :reactor ) { Async ::Reactor . new }
14
14
15
- describe '.yield' do
15
+ with '.yield' do
16
16
it "can yield back to scheduler" do
17
17
state = nil
18
18
142
142
end
143
143
end . to raise_exception ( SignalException , message : be =~ /TERM/ )
144
144
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
145
157
end
146
158
147
159
with '#yield' do
You can’t perform that action at this time.
0 commit comments