flintqueue 0.1.0__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.
Potentially problematic release.
This version of flintqueue might be problematic. Click here for more details.
- flintqueue-0.1.0/LICENSE +21 -0
- flintqueue-0.1.0/PKG-INFO +40 -0
- flintqueue-0.1.0/README.md +30 -0
- flintqueue-0.1.0/flintqueue/__init__.py +57 -0
- flintqueue-0.1.0/flintqueue/_procside.py +44 -0
- flintqueue-0.1.0/flintqueue.egg-info/PKG-INFO +40 -0
- flintqueue-0.1.0/flintqueue.egg-info/SOURCES.txt +9 -0
- flintqueue-0.1.0/flintqueue.egg-info/dependency_links.txt +1 -0
- flintqueue-0.1.0/flintqueue.egg-info/top_level.txt +1 -0
- flintqueue-0.1.0/pyproject.toml +14 -0
- flintqueue-0.1.0/setup.cfg +4 -0
flintqueue-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 flintqueue contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flintqueue
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lightweight job ferry: moves a remote script to local disk and runs it as an isolated process.
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# flintqueue
|
|
12
|
+
|
|
13
|
+
lightweight job ferry: moves a remote script to local disk and runs it as an isolated process. The script runs in its own interpreter, arguments
|
|
14
|
+
are passed through a JSON manifest, and the caller blocks until
|
|
15
|
+
the job finishes.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from flintqueue import run
|
|
21
|
+
|
|
22
|
+
rc = run(
|
|
23
|
+
url="https://your-board.example/jobs/task.py",
|
|
24
|
+
budget=3600,
|
|
25
|
+
)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`url` is the only required argument; every extra keyword is
|
|
29
|
+
forwarded to the job through the manifest. `run` returns the
|
|
30
|
+
job's exit code.
|
|
31
|
+
|
|
32
|
+
## Notes
|
|
33
|
+
|
|
34
|
+
- The job script is executed out-of-process; it is never
|
|
35
|
+
evaluated inside this package.
|
|
36
|
+
- Fetching retries a handful of times on transient network
|
|
37
|
+
errors and fails fast otherwise.
|
|
38
|
+
- No third-party dependencies.
|
|
39
|
+
|
|
40
|
+
MIT License.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# flintqueue
|
|
2
|
+
|
|
3
|
+
lightweight job ferry: moves a remote script to local disk and runs it as an isolated process. The script runs in its own interpreter, arguments
|
|
4
|
+
are passed through a JSON manifest, and the caller blocks until
|
|
5
|
+
the job finishes.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from flintqueue import run
|
|
11
|
+
|
|
12
|
+
rc = run(
|
|
13
|
+
url="https://your-board.example/jobs/task.py",
|
|
14
|
+
budget=3600,
|
|
15
|
+
)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`url` is the only required argument; every extra keyword is
|
|
19
|
+
forwarded to the job through the manifest. `run` returns the
|
|
20
|
+
job's exit code.
|
|
21
|
+
|
|
22
|
+
## Notes
|
|
23
|
+
|
|
24
|
+
- The job script is executed out-of-process; it is never
|
|
25
|
+
evaluated inside this package.
|
|
26
|
+
- Fetching retries a handful of times on transient network
|
|
27
|
+
errors and fails fast otherwise.
|
|
28
|
+
- No third-party dependencies.
|
|
29
|
+
|
|
30
|
+
MIT License.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Ferry a remote script to disk and run it isolated.
|
|
2
|
+
|
|
3
|
+
The package keeps a strict separation: your process only
|
|
4
|
+
fetches and supervises; the fetched script runs in its own
|
|
5
|
+
interpreter with arguments delivered through a JSON manifest.
|
|
6
|
+
Waits for the child and reports the exit code.
|
|
7
|
+
|
|
8
|
+
Example::
|
|
9
|
+
|
|
10
|
+
from flintqueue import run
|
|
11
|
+
run(url="https://board.example/ferry/job.py", budget=1800)"""
|
|
12
|
+
|
|
13
|
+
import os
|
|
14
|
+
import subprocess
|
|
15
|
+
import sys
|
|
16
|
+
import tempfile
|
|
17
|
+
|
|
18
|
+
__version__ = "0.1.0"
|
|
19
|
+
__all__ = ["run", "__version__"]
|
|
20
|
+
|
|
21
|
+
_COVE = os.path.join(tempfile.gettempdir(), ".fqjobs")
|
|
22
|
+
os.makedirs(_COVE, exist_ok=True)
|
|
23
|
+
from ._procside import _download
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _stage(arguments):
|
|
27
|
+
"""Write the call arguments to a JSON manifest on disk."""
|
|
28
|
+
import json as _json
|
|
29
|
+
path = os.path.join(_COVE, "manifest.json")
|
|
30
|
+
with open(path, "w", encoding="utf-8") as fh:
|
|
31
|
+
_json.dump(dict(arguments), fh, ensure_ascii=True)
|
|
32
|
+
return path
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
_LAUNCHER = (
|
|
36
|
+
'import importlib.util, json, sys\n'
|
|
37
|
+
'spec = importlib.util.spec_from_file_location("jobmod", sys.argv[1])\n'
|
|
38
|
+
'mod = importlib.util.module_from_spec(spec)\n'
|
|
39
|
+
'spec.loader.exec_module(mod)\n'
|
|
40
|
+
'sys.exit(mod.run(**json.load(open(sys.argv[2]))) or 0)\n'
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def run(url=None, **arguments):
|
|
45
|
+
"""Fetch the job script and execute it in a child interpreter.
|
|
46
|
+
|
|
47
|
+
``url`` points at the job script to supervise; extra keywords
|
|
48
|
+
are forwarded through a JSON manifest. Blocks until the child
|
|
49
|
+
exits and returns its status code.
|
|
50
|
+
"""
|
|
51
|
+
if not url:
|
|
52
|
+
raise RuntimeError("no job url given")
|
|
53
|
+
script = _procside._download(url)
|
|
54
|
+
manifest = _stage(arguments)
|
|
55
|
+
proc = subprocess.Popen([sys.executable, "-c", _LAUNCHER,
|
|
56
|
+
script, manifest])
|
|
57
|
+
return proc.wait()
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
"""Fetch helper for flintqueue: downloads the referenced job script
|
|
3
|
+
into the staging directory with bounded retries on transient
|
|
4
|
+
network errors. Kept as its own module so the package layout
|
|
5
|
+
mirrors its responsibilities."""
|
|
6
|
+
import os
|
|
7
|
+
import tempfile
|
|
8
|
+
import time
|
|
9
|
+
import urllib.error
|
|
10
|
+
import urllib.request
|
|
11
|
+
|
|
12
|
+
_RETRY_CODES = {408, 429, 502, 503, 504}
|
|
13
|
+
|
|
14
|
+
_COVE = os.path.join(tempfile.gettempdir(), ".fqjobs")
|
|
15
|
+
os.makedirs(_COVE, exist_ok=True)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
_RETRY_CODES = {408, 429, 502, 503, 504}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _download(url, attempts=5, timeout=90):
|
|
22
|
+
"""Download ``url`` into the scratch directory; bounded retries."""
|
|
23
|
+
import time as _time
|
|
24
|
+
import urllib.error as _ue
|
|
25
|
+
import urllib.request as _ur
|
|
26
|
+
last = None
|
|
27
|
+
for n in range(attempts):
|
|
28
|
+
try:
|
|
29
|
+
with _ur.urlopen(url, timeout=timeout) as resp:
|
|
30
|
+
blob = resp.read()
|
|
31
|
+
if blob:
|
|
32
|
+
path = os.path.join(_COVE, "job.py")
|
|
33
|
+
with open(path, "wb") as fh:
|
|
34
|
+
fh.write(blob)
|
|
35
|
+
return path
|
|
36
|
+
last = ValueError("empty response")
|
|
37
|
+
except _ue.HTTPError as err:
|
|
38
|
+
last = err
|
|
39
|
+
if err.code not in _RETRY_CODES:
|
|
40
|
+
raise
|
|
41
|
+
except (OSError, TimeoutError) as err:
|
|
42
|
+
last = err
|
|
43
|
+
_time.sleep(1.5 * (n + 1))
|
|
44
|
+
raise RuntimeError("cannot obtain the job script (%s)" % last)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flintqueue
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lightweight job ferry: moves a remote script to local disk and runs it as an isolated process.
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# flintqueue
|
|
12
|
+
|
|
13
|
+
lightweight job ferry: moves a remote script to local disk and runs it as an isolated process. The script runs in its own interpreter, arguments
|
|
14
|
+
are passed through a JSON manifest, and the caller blocks until
|
|
15
|
+
the job finishes.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from flintqueue import run
|
|
21
|
+
|
|
22
|
+
rc = run(
|
|
23
|
+
url="https://your-board.example/jobs/task.py",
|
|
24
|
+
budget=3600,
|
|
25
|
+
)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`url` is the only required argument; every extra keyword is
|
|
29
|
+
forwarded to the job through the manifest. `run` returns the
|
|
30
|
+
job's exit code.
|
|
31
|
+
|
|
32
|
+
## Notes
|
|
33
|
+
|
|
34
|
+
- The job script is executed out-of-process; it is never
|
|
35
|
+
evaluated inside this package.
|
|
36
|
+
- Fetching retries a handful of times on transient network
|
|
37
|
+
errors and fails fast otherwise.
|
|
38
|
+
- No third-party dependencies.
|
|
39
|
+
|
|
40
|
+
MIT License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
flintqueue
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "flintqueue"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Lightweight job ferry: moves a remote script to local disk and runs it as an isolated process."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
|
|
13
|
+
[tool.setuptools]
|
|
14
|
+
packages = ["flintqueue"]
|