Skip to content

Commit c6ea09a

Browse files
authored
Fix cleanup of simple servers. (#1294)
* Fix clean up of simple servers. * CHANGELOG
1 parent 2cf4c80 commit c6ea09a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ Write the date in place of the "Unreleased" in the case a new version is release
77

88
### Fixed
99

10-
- Explicitly specified `"Content-Type": "application/json"` in the request headers to
11-
comply with stricter payload parsing in FastAPI >= 0.132.0.
10+
- Explicitly specified `"Content-Type": "application/json"` in the request
11+
headers to comply with stricter payload parsing in FastAPI >= 0.132.0.
12+
- Servers started by the new function `tiled.client.simple` did not stop
13+
cleanly at interpreter shutdown, causing a hangup.
1214

1315
## v0.2.5 (2026-02-20)
1416

tiled/client/constructors.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import atexit
21
import collections
32
import collections.abc
43
import pathlib
4+
import threading
55
import warnings
66
from typing import Optional, Union
77
from urllib.parse import parse_qs, urlparse
@@ -316,4 +316,9 @@ def _cleanup_servers():
316316

317317

318318
SERVERS = [] # servers spawned using simple
319-
atexit.register(_cleanup_servers)
319+
# The threading module has its own (internal) atexit
320+
# mechanism that runs at thread shutdown, prior to the atexit
321+
# mechanism that runs at interpreter shutdown.
322+
# We need to intervene at that layer to close the portal, or else
323+
# we will wait forever for a thread run by the portal to join().
324+
threading._register_atexit(_cleanup_servers)

0 commit comments

Comments
 (0)