mirror of https://github.com/jackc/pgx.git
Wrap stdlib Conn.Close() and Stmt.Close() with default 5 seconds timeout.
parent
e5920c3ad9
commit
e27a6e71b5
|
@ -225,7 +225,9 @@ func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, e
|
|||
}
|
||||
|
||||
func (c *Conn) Close() error {
|
||||
return c.conn.Close(context.Background())
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer cancel()
|
||||
return c.conn.Close(ctx)
|
||||
}
|
||||
|
||||
func (c *Conn) Begin() (driver.Tx, error) {
|
||||
|
@ -325,7 +327,9 @@ type Stmt struct {
|
|||
}
|
||||
|
||||
func (s *Stmt) Close() error {
|
||||
return s.conn.conn.Deallocate(context.Background(), s.sd.Name)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer cancel()
|
||||
return s.conn.conn.Deallocate(ctx, s.sd.Name)
|
||||
}
|
||||
|
||||
func (s *Stmt) NumInput() int {
|
||||
|
|
Loading…
Reference in New Issue