Skip to content

Commit 2d3773c

Browse files
committed
Workerman Coroutine
1 parent 2017397 commit 2d3773c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/DatabaseManager.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
use Illuminate\Database\DatabaseManager as BaseDatabaseManager;
66
use Throwable;
77
use Webman\Context;
8-
use Webman\Coroutine\Pool;
8+
use Workerman\Coroutine\Coroutine;
9+
use Workerman\Coroutine\Pool;
910

1011
/**
1112
* Class DatabaseManager
@@ -51,7 +52,7 @@ public function connection($name = null)
5152
$connection = static::$pools[$name]->get();
5253
Context::set($key, $connection);
5354
} finally {
54-
Context::onDestroy(function () use ($connection, $name) {
55+
Coroutine::defer(function () use ($connection, $name) {
5556
try {
5657
$connection && static::$pools[$name]->put($connection);
5758
} catch (Throwable) {

0 commit comments

Comments
 (0)