File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,10 @@ final protected function setTimeout(int $timeout)
196
196
{
197
197
$ this ->timeout = $ timeout ;
198
198
199
+ if (isset ($ this ->timeoutId )) {
200
+ Loop::cancel ($ this ->timeoutId );
201
+ }
202
+
199
203
$ this ->timeoutId = Loop::delay ($ timeout , function () use ($ timeout ) {
200
204
Loop::stop ();
201
205
Loop::setErrorHandler (null );
Original file line number Diff line number Diff line change @@ -121,6 +121,16 @@ public function testSetTimeout(): \Generator
121
121
$ this ->assertNull (yield delay (250 ));
122
122
}
123
123
124
+ public function testSetTimeoutReplace (): \Generator
125
+ {
126
+ $ this ->setTimeout (500 );
127
+ $ this ->setTimeout (1000 );
128
+
129
+ yield delay (750 );
130
+
131
+ $ this ->expectNotToPerformAssertions ();
132
+ }
133
+
124
134
public function testSetTimeoutWithCoroutine (): \Generator
125
135
{
126
136
$ this ->setTimeout (100 );
You can’t perform that action at this time.
0 commit comments