If _reset is not set there is little work to do so the overhead of a
context switch is measurable and not necessary.
return
# Use a worker to perform eventual maintenance work in a separate thread
- self.run_task(ReturnConnection(self, conn))
+ if self._reset:
+ self.run_task(ReturnConnection(self, conn))
+ else:
+ await self._return_connection(conn)
async def close(self, timeout: float = 5.0) -> None:
"""Close the pool and make it unavailable to new clients.
return
# Use a worker to perform eventual maintenance work in a separate thread
- self.run_task(ReturnConnection(self, conn))
+ if self._reset:
+ self.run_task(ReturnConnection(self, conn))
+ else:
+ self._return_connection(conn)
def close(self, timeout: float = 1.0) -> None:
"""Close the pool and make it unavailable to new clients.