1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-22 21:51:34 +01:00

Properly handle execution time limits (fixes "Must call resume() or throw() before calling suspend() again" errors)

This commit is contained in:
Daniil Gentili 2023-02-07 19:19:50 +01:00
parent de081572f0
commit 8e3df1e7bf
2 changed files with 15 additions and 1 deletions

2
docs

@ -1 +1 @@
Subproject commit a219e8a4f31000bf366993ab269b9ea2a95bbe2c Subproject commit 846f4a03749d57ac166276445f95662dff45eb67

View File

@ -20,6 +20,9 @@ declare(strict_types=1);
namespace danog\MadelineProto; namespace danog\MadelineProto;
use ReflectionClass;
use Revolt\EventLoop;
use function Amp\ByteStream\getStdin; use function Amp\ByteStream\getStdin;
/** /**
@ -48,6 +51,17 @@ final class Shutdown
*/ */
private static function shutdown(): void private static function shutdown(): void
{ {
$obj = EventLoop::getSuspension();
$reflection = new ReflectionClass($obj);
$reflection->getProperty('pending')->setValue($obj, false);
$obj = EventLoop::getDriver();
$reflection = new ReflectionClass(AbstractDriver::class);
if (!$reflection->getProperty('callbackFiber')->isInitialized($obj)
|| $reflection->getProperty('callbackFiber')->getValue($obj)->isTerminated()
) {
$reflection->getMethod('createCallbackFiber')->invoke($obj);
}
foreach (self::$callbacks as $callback) { foreach (self::$callbacks as $callback) {
$callback(); $callback();
} }