Skip to content

Commit

Permalink
Merge pull request #39 from uktrade/feat/better-user-facing-name
Browse files Browse the repository at this point in the history
feat: rename termination_thread_timeout to cleanup_timeout
  • Loading branch information
michalc committed May 24, 2023
2 parents f9b0ddf + 85af64f commit d0b7360
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ with \

The API a single context manager `pg_force_execute`.

`pg_force_execute`(conn, delay=datetime.timedelta(minutes=5), check_interval=datetime.timedelta(seconds=1), termination_thread_timeout=datetime.timedelta(seconds=10), logger=logging.getLogger("pg_force_execute"))
`pg_force_execute`(conn, delay=datetime.timedelta(minutes=5), check_interval=datetime.timedelta(seconds=1), cleanup_timeout=datetime.timedelta(seconds=10), logger=logging.getLogger("pg_force_execute"))

- `conn` - A [SQLAlchemy connection](https://docs.sqlalchemy.org/en/20/core/connections.html#sqlalchemy.engine.Connection) that will be unblocked

- `delay` (optional) - How long to wait before attempting to terminate backends blocking `conn`

- `check_interval` (optional) - The interval between repeated attempted to terminate backends blocking `conn`
- `check_interval` (optional) - The interval between repeated attempts to terminate backends blocking `conn`

- `termination_thread_timeout` (optional) - How long to wait for the termination to complete
- `cleanup_timeout` (optional) - How long to wait for resources to be cleaned up before allowing exit of the context manager

For usual operation this parameter shouldn't need to be changed.

- `logger` (optional) The Python logger instance through which to log

Expand Down
4 changes: 2 additions & 2 deletions pg_force_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def pg_force_execute(conn,
delay=datetime.timedelta(minutes=5),
check_interval=datetime.timedelta(seconds=1),
termination_thread_timeout=datetime.timedelta(seconds=10),
cleanup_timeout=datetime.timedelta(seconds=10),
logger=logging.getLogger("pg_force_execute"),
):
cancel_exception = None
Expand Down Expand Up @@ -62,6 +62,6 @@ def force_unblock(pid, exit):
yield
finally:
exit.set()
t.join(timeout=termination_thread_timeout.total_seconds())
t.join(timeout=cleanup_timeout.total_seconds())
if cancel_exception is not None:
raise cancel_exception

0 comments on commit d0b7360

Please sign in to comment.