Closed ejz closed 3 years ago
This looks like a bug to me rather than something that should be suppressed.
@Ejz Can you give me any information on the circumstances in which you saw this error?
Example code to reproduce this behavior:
use Amp\Postgres;
use Amp\Postgres\ConnectionConfig;
Amp\Loop::run(function () {
$config = ConnectionConfig::fromString('host=localhost user=root dbname=test');
/** @var Postgres\Pool $pool */
$pool = Postgres\pool($config);
yield $pool->query('SELECT * FROM generate_series(1, 999);');
\Amp\call(function () use ($pool) {
/** @var \Amp\Sql\Transaction $transaction */
$transaction = yield $pool->beginTransaction();
$transaction->query('create table if not exists testtest ();');
$transaction->commit();
exit;
});
});
This error is possible to repeat without exit
, maybe I'll find short example for us.
Second example:
use Amp\Postgres;
use Amp\Postgres\ConnectionConfig;
use Amp\Promise;
$config = ConnectionConfig::fromString('host=localhost user=roquie dbname=roquie');
/** @var Postgres\Pool $pool */
$pool = Postgres\pool($config);
Promise\wait($pool->query('SELECT * FROM generate_series(1, 999);'));
$promise = \Amp\call(function () use ($pool) {
/** @var \Amp\Sql\Transaction $transaction */
$transaction = yield $pool->beginTransaction();
$transaction->query('create table if not exists testtest ();');
$transaction->commit();
});
Promise\wait($promise);
$pool->close();
Workaround, – use Promise\wait(new Delayed(100));
before $pool->close();
This error happens because I forgot wait a promise in the code above :) It's not a critical issue but reserve time consuming to resolve it.
$config = ConnectionConfig::fromString('host=localhost user=roquie dbname=roquie');
/** @var Postgres\Pool $pool */
$pool = Postgres\pool($config);
Promise\wait($pool->query('SELECT * FROM generate_series(1, 999);'));
$promise = \Amp\call(function () use ($pool) {
/** @var \Amp\Sql\Transaction $transaction */
$transaction = yield $pool->beginTransaction();
yield $transaction->query('create table if not exists testtest ();');
yield $transaction->commit();
});
Promise\wait($promise);
$pool->close();
Could you mute'em, please with
@
? They are happened especially while working with a database pool.