hashserver 1.0.1__tar.gz → 1.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hashserver-1.0.1/hashserver.egg-info → hashserver-1.0.3}/PKG-INFO +4 -4
- {hashserver-1.0.1 → hashserver-1.0.3}/README.md +3 -3
- {hashserver-1.0.1 → hashserver-1.0.3}/hash_file_response.py +0 -4
- {hashserver-1.0.1 → hashserver-1.0.3/hashserver.egg-info}/PKG-INFO +4 -4
- {hashserver-1.0.1 → hashserver-1.0.3}/hashserver.py +19 -10
- {hashserver-1.0.1 → hashserver-1.0.3}/pyproject.toml +1 -1
- {hashserver-1.0.1 → hashserver-1.0.3}/tests/test_port_range.py +29 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/LICENSE.txt +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/hashserver.egg-info/SOURCES.txt +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/hashserver.egg-info/dependency_links.txt +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/hashserver.egg-info/entry_points.txt +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/hashserver.egg-info/requires.txt +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/hashserver.egg-info/top_level.txt +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/setup.cfg +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/tests/test_basic.py +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/tests/test_basic_uvicorn.py +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/tests/test_global_lock.py +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/tests/test_has_buffers.py +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/tests/test_lock.py +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/tests/test_lock_uvicorn.py +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/tests/test_promises.py +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/tests/test_put_read.py +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/tests/test_put_read_big.py +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/tests/test_simple_put.py +0 -0
- {hashserver-1.0.1 → hashserver-1.0.3}/tests/test_timeout.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hashserver
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Simple FastAPI-based hash server
|
|
5
5
|
Author: Sjoerd de Vries
|
|
6
6
|
License-Expression: MIT
|
|
@@ -78,13 +78,13 @@ Serve buffers from a local directory:
|
|
|
78
78
|
hashserver ./my-buffers
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
This starts the server under uvicorn on port
|
|
81
|
+
This starts the server under uvicorn on a random free port in the dynamic/private range (`49152-65535`). Run `hashserver -h` for all options.
|
|
82
82
|
|
|
83
83
|
### Storing and retrieving a buffer
|
|
84
84
|
|
|
85
85
|
```bash
|
|
86
86
|
# Start a writable server
|
|
87
|
-
hashserver ./my-buffers --writable
|
|
87
|
+
hashserver ./my-buffers --writable --port 8000
|
|
88
88
|
|
|
89
89
|
# Compute the SHA-256 checksum and upload
|
|
90
90
|
CHECKSUM=$(python3 -c "
|
|
@@ -156,7 +156,7 @@ Requires `--writable`.
|
|
|
156
156
|
| `--layout` | Directory layout: `prefix` or `flat` | `prefix` |
|
|
157
157
|
| `--extra-dirs` | Semicolon-separated list of extra read-only buffer directories | — |
|
|
158
158
|
| `--host` | Listen address | `127.0.0.1` |
|
|
159
|
-
| `--port` | Listen port | `
|
|
159
|
+
| `--port` | Listen port | random free port in `49152-65535` |
|
|
160
160
|
| `--port-range START END` | Pick a random free port in range (mutually exclusive with `--port`) | — |
|
|
161
161
|
| `--status-file` | JSON file for reporting server status | — |
|
|
162
162
|
| `--timeout` | Shut down after this many seconds of inactivity | — |
|
|
@@ -52,13 +52,13 @@ Serve buffers from a local directory:
|
|
|
52
52
|
hashserver ./my-buffers
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
This starts the server under uvicorn on port
|
|
55
|
+
This starts the server under uvicorn on a random free port in the dynamic/private range (`49152-65535`). Run `hashserver -h` for all options.
|
|
56
56
|
|
|
57
57
|
### Storing and retrieving a buffer
|
|
58
58
|
|
|
59
59
|
```bash
|
|
60
60
|
# Start a writable server
|
|
61
|
-
hashserver ./my-buffers --writable
|
|
61
|
+
hashserver ./my-buffers --writable --port 8000
|
|
62
62
|
|
|
63
63
|
# Compute the SHA-256 checksum and upload
|
|
64
64
|
CHECKSUM=$(python3 -c "
|
|
@@ -130,7 +130,7 @@ Requires `--writable`.
|
|
|
130
130
|
| `--layout` | Directory layout: `prefix` or `flat` | `prefix` |
|
|
131
131
|
| `--extra-dirs` | Semicolon-separated list of extra read-only buffer directories | — |
|
|
132
132
|
| `--host` | Listen address | `127.0.0.1` |
|
|
133
|
-
| `--port` | Listen port | `
|
|
133
|
+
| `--port` | Listen port | random free port in `49152-65535` |
|
|
134
134
|
| `--port-range START END` | Pick a random free port in range (mutually exclusive with `--port`) | — |
|
|
135
135
|
| `--status-file` | JSON file for reporting server status | — |
|
|
136
136
|
| `--timeout` | Shut down after this many seconds of inactivity | — |
|
|
@@ -73,7 +73,6 @@ class HashFileResponse(FileResponse):
|
|
|
73
73
|
media_type: typing.Optional[str] = None,
|
|
74
74
|
background: typing.Optional[BackgroundTask] = None,
|
|
75
75
|
stat_result: typing.Optional[os.stat_result] = None,
|
|
76
|
-
method: typing.Optional[str] = None,
|
|
77
76
|
content_disposition_type: str = "attachment",
|
|
78
77
|
extra_dirs: typing.Optional[typing.List[str]] = None,
|
|
79
78
|
) -> None:
|
|
@@ -92,7 +91,6 @@ class HashFileResponse(FileResponse):
|
|
|
92
91
|
background=background,
|
|
93
92
|
filename=filename,
|
|
94
93
|
stat_result=stat_result,
|
|
95
|
-
method=method,
|
|
96
94
|
content_disposition_type=content_disposition_type,
|
|
97
95
|
)
|
|
98
96
|
self.directory = directory
|
|
@@ -209,7 +207,6 @@ class PrefixHashFileResponse(HashFileResponse):
|
|
|
209
207
|
media_type: typing.Optional[str] = None,
|
|
210
208
|
background: typing.Optional[BackgroundTask] = None,
|
|
211
209
|
stat_result: typing.Optional[os.stat_result] = None,
|
|
212
|
-
method: typing.Optional[str] = None,
|
|
213
210
|
content_disposition_type: str = "attachment",
|
|
214
211
|
extra_dirs: typing.Optional[typing.List[str]] = None,
|
|
215
212
|
) -> None:
|
|
@@ -222,7 +219,6 @@ class PrefixHashFileResponse(HashFileResponse):
|
|
|
222
219
|
media_type=media_type,
|
|
223
220
|
background=background,
|
|
224
221
|
stat_result=stat_result,
|
|
225
|
-
method=method,
|
|
226
222
|
content_disposition_type=content_disposition_type,
|
|
227
223
|
extra_dirs=extra_dirs,
|
|
228
224
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hashserver
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Simple FastAPI-based hash server
|
|
5
5
|
Author: Sjoerd de Vries
|
|
6
6
|
License-Expression: MIT
|
|
@@ -78,13 +78,13 @@ Serve buffers from a local directory:
|
|
|
78
78
|
hashserver ./my-buffers
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
This starts the server under uvicorn on port
|
|
81
|
+
This starts the server under uvicorn on a random free port in the dynamic/private range (`49152-65535`). Run `hashserver -h` for all options.
|
|
82
82
|
|
|
83
83
|
### Storing and retrieving a buffer
|
|
84
84
|
|
|
85
85
|
```bash
|
|
86
86
|
# Start a writable server
|
|
87
|
-
hashserver ./my-buffers --writable
|
|
87
|
+
hashserver ./my-buffers --writable --port 8000
|
|
88
88
|
|
|
89
89
|
# Compute the SHA-256 checksum and upload
|
|
90
90
|
CHECKSUM=$(python3 -c "
|
|
@@ -156,7 +156,7 @@ Requires `--writable`.
|
|
|
156
156
|
| `--layout` | Directory layout: `prefix` or `flat` | `prefix` |
|
|
157
157
|
| `--extra-dirs` | Semicolon-separated list of extra read-only buffer directories | — |
|
|
158
158
|
| `--host` | Listen address | `127.0.0.1` |
|
|
159
|
-
| `--port` | Listen port | `
|
|
159
|
+
| `--port` | Listen port | random free port in `49152-65535` |
|
|
160
160
|
| `--port-range START END` | Pick a random free port in range (mutually exclusive with `--port`) | — |
|
|
161
161
|
| `--status-file` | JSON file for reporting server status | — |
|
|
162
162
|
| `--timeout` | Shut down after this many seconds of inactivity | — |
|
|
@@ -44,6 +44,8 @@ checksum_constructor = HASH_ALGORITHMS[DEFAULT_HASH_ALGORITHM]
|
|
|
44
44
|
|
|
45
45
|
STATUS_FILE_WAIT_TIMEOUT = 20.0
|
|
46
46
|
INACTIVITY_CHECK_INTERVAL = 1.0
|
|
47
|
+
DEFAULT_RANDOM_PORT_START = 49152
|
|
48
|
+
DEFAULT_RANDOM_PORT_END = 65535
|
|
47
49
|
|
|
48
50
|
|
|
49
51
|
INACTIVITY_STATE = {
|
|
@@ -363,10 +365,26 @@ If not specified, this argument is read from HASHSERVER_EXTRA_DIRS, if present""
|
|
|
363
365
|
configure_lock_timeout(args.lock_timeout)
|
|
364
366
|
status_file_path = args.status_file
|
|
365
367
|
timeout_seconds = args.timeout
|
|
368
|
+
if args.port_range:
|
|
369
|
+
start, end = args.port_range
|
|
370
|
+
try:
|
|
371
|
+
selected_port = pick_random_free_port(args.host, start, end)
|
|
372
|
+
except BaseException as exc:
|
|
373
|
+
raise_startup_error(exc)
|
|
374
|
+
elif args.port is not None:
|
|
375
|
+
selected_port = args.port
|
|
376
|
+
else:
|
|
377
|
+
try:
|
|
378
|
+
selected_port = pick_random_free_port(
|
|
379
|
+
args.host, DEFAULT_RANDOM_PORT_START, DEFAULT_RANDOM_PORT_END
|
|
380
|
+
)
|
|
381
|
+
except BaseException as exc:
|
|
382
|
+
raise_startup_error(exc)
|
|
383
|
+
args.port = selected_port
|
|
366
384
|
if status_file_path:
|
|
367
385
|
status_file_contents = wait_for_status_file(status_file_path)
|
|
368
386
|
status_tracker = StatusFileTracker(
|
|
369
|
-
status_file_path, status_file_contents,
|
|
387
|
+
status_file_path, status_file_contents, selected_port
|
|
370
388
|
)
|
|
371
389
|
if timeout_seconds is not None and timeout_seconds <= 0:
|
|
372
390
|
raise_startup_error(RuntimeError("--timeout must be a positive number"))
|
|
@@ -377,15 +395,6 @@ If not specified, this argument is read from HASHSERVER_EXTRA_DIRS, if present""
|
|
|
377
395
|
else:
|
|
378
396
|
extra_dirs = []
|
|
379
397
|
layout = args.layout
|
|
380
|
-
if args.port_range:
|
|
381
|
-
start, end = args.port_range
|
|
382
|
-
try:
|
|
383
|
-
selected_port = pick_random_free_port(args.host, start, end)
|
|
384
|
-
except BaseException as exc:
|
|
385
|
-
raise_startup_error(exc)
|
|
386
|
-
else:
|
|
387
|
-
selected_port = args.port if args.port is not None else 8000
|
|
388
|
-
args.port = selected_port
|
|
389
398
|
if status_tracker:
|
|
390
399
|
status_tracker.port = selected_port
|
|
391
400
|
|
|
@@ -5,6 +5,9 @@ import requests
|
|
|
5
5
|
|
|
6
6
|
from .utils import allocate_port_range, start_server, wait_for_server
|
|
7
7
|
|
|
8
|
+
DEFAULT_RANDOM_PORT_START = 49152
|
|
9
|
+
DEFAULT_RANDOM_PORT_END = 65535
|
|
10
|
+
|
|
8
11
|
|
|
9
12
|
def wait_for_port(process, timeout: float = 10.0):
|
|
10
13
|
deadline = time.monotonic() + timeout
|
|
@@ -52,3 +55,29 @@ def test_port_range(bufferdir):
|
|
|
52
55
|
print("Initial logs:")
|
|
53
56
|
for line in captured:
|
|
54
57
|
print(line, end="")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def test_random_port_default(bufferdir):
|
|
61
|
+
command = [
|
|
62
|
+
"hashserver",
|
|
63
|
+
str(bufferdir),
|
|
64
|
+
"--layout",
|
|
65
|
+
"flat",
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
with start_server(command, text=True) as process:
|
|
69
|
+
port, captured = wait_for_port(process)
|
|
70
|
+
assert port is not None, "Server did not report the selected port"
|
|
71
|
+
assert DEFAULT_RANDOM_PORT_START <= port <= DEFAULT_RANDOM_PORT_END, port
|
|
72
|
+
assert port != 8000
|
|
73
|
+
|
|
74
|
+
wait_for_server(port)
|
|
75
|
+
|
|
76
|
+
response = requests.get(f"http://127.0.0.1:{port}/healthcheck", timeout=5)
|
|
77
|
+
assert response.status_code == 200, response.text
|
|
78
|
+
assert response.text == "OK"
|
|
79
|
+
|
|
80
|
+
if captured:
|
|
81
|
+
print("Initial logs:")
|
|
82
|
+
for line in captured:
|
|
83
|
+
print(line, end="")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|