We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 56ea4dd commit c37451aCopy full SHA for c37451a
src/DatabaseManager.php
@@ -5,7 +5,6 @@
5
use Illuminate\Database\DatabaseManager as BaseDatabaseManager;
6
use Throwable;
7
use Webman\Context;
8
-use Workerman\Coroutine\Coroutine;
9
use Workerman\Coroutine\Pool;
10
11
/**
@@ -52,7 +51,8 @@ public function connection($name = null)
52
51
$connection = static::$pools[$name]->get();
53
Context::set($key, $connection);
54
} finally {
55
- Coroutine::defer(function () use ($connection, $name) {
+ // We cannot use Coroutine::defer() because we may not be in a coroutine environment currently.
+ Context::onDestroy(function () use ($connection, $name) {
56
try {
57
$connection && static::$pools[$name]->put($connection);
58
} catch (Throwable) {
0 commit comments