Skip to content

Commit 6218909

Browse files
authored
bump to tremolo 0.4.0 (#75)
* bump to tremolo 0.4.0 * update ci
1 parent 29a7f1f commit 6218909

6 files changed

Lines changed: 15 additions & 28 deletions

File tree

.github/workflows/build_and_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- 'cp311-*'
5151
- 'cp312-*'
5252
- 'cp313-*'
53-
- 'pp310-*'
53+
- 'pp311-*'
5454
cibw_arch: ['x86_64']
5555
timeout-minutes: 10
5656
steps:

.github/workflows/tests_and_coverage.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ jobs:
1616
python_version:
1717
- '3.13'
1818
- '3.12'
19-
- '3.11'
19+
- '3.10'
2020
- '3.9'
2121
- '3.8'
2222
- '3.7'
23-
- 'pypy3.10'
24-
os: ['ubuntu-20.04', 'windows-latest']
23+
- 'pypy3.11'
24+
os: ['ubuntu-22.04', 'windows-latest']
2525
timeout-minutes: 10
2626
steps:
2727
- uses: actions/checkout@v4
@@ -48,7 +48,6 @@ jobs:
4848
run: |
4949
python -m pip install --upgrade pip
5050
python -m pip install --upgrade coverage
51-
python -m pip install --upgrade awaiter
5251
python -m pip install --upgrade tremolo
5352
if: ${{ contains(env.FILES_MODIFIED, '.py') }}
5453

@@ -60,7 +59,7 @@ jobs:
6059
python -m flake8 httpout/
6160
if: |
6261
contains(env.FILES_MODIFIED, '.py') &&
63-
matrix.os == 'ubuntu-20.04' && matrix.python_version == '3.13'
62+
matrix.os == 'ubuntu-22.04' && matrix.python_version == '3.13'
6463
6564
- name: Run tests
6665
run: python -m tests
@@ -110,7 +109,6 @@ jobs:
110109
echo "$HOME/.local/bin" >> $GITHUB_PATH
111110
python -m pip install --upgrade pip
112111
python -m pip install --upgrade coverage
113-
python -m pip install --upgrade awaiter
114112
python -m pip install --upgrade tremolo
115113
if: ${{ contains(env.FILES_MODIFIED, '.py') }}
116114

httpout/httpout.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from types import ModuleType
99

10-
from awaiter import MultiThreadExecutor
1110
from tremolo.exceptions import BadRequest, NotFound, Forbidden
1211
from tremolo.lib.websocket import WebSocket
1312
from tremolo.utils import html_escape
@@ -22,15 +21,13 @@
2221
class HTTPOut:
2322
def __init__(self, app):
2423
app.add_hook(self._on_worker_start, 'worker_start')
25-
app.add_hook(self._on_worker_stop, 'worker_stop')
24+
app.add_hook(self._on_close, 'close')
2625
app.add_middleware(self._on_request, 'request', priority=9999) # low
27-
app.add_middleware(self._on_close, 'close')
2826

2927
async def _on_worker_start(self, **worker):
3028
loop = worker['loop']
3129
logger = worker['logger']
3230
g = worker['globals']
33-
thread_pool_size = g.options.get('thread_pool_size', 5)
3431
document_root = os.path.abspath(
3532
g.options.get('document_root', os.getcwd())
3633
)
@@ -152,17 +149,10 @@ def ho_import(name, globals=None, locals=None, fromlist=(), level=0):
152149

153150
g.wait = wait
154151
g.caches = {}
155-
g.executor = MultiThreadExecutor(thread_pool_size)
156-
g.executor.start()
157152

158153
if module:
159154
exec_module(module)
160155

161-
async def _on_worker_stop(self, **worker):
162-
g = worker['globals']
163-
164-
await g.executor.shutdown()
165-
166156
async def _on_request(self, **server):
167157
request = server['request']
168158
response = server['response']
@@ -258,7 +248,8 @@ async def _on_request(self, **server):
258248

259249
try:
260250
# execute module in another thread
261-
result = await g.executor.submit(exec_module, module, code)
251+
result = await g.executor.submit(exec_module,
252+
args=(module, code))
262253
await server['response'].join()
263254

264255
if result:
@@ -273,7 +264,8 @@ async def _on_request(self, **server):
273264
await server['response'].handle_exception(exc)
274265
finally:
275266
await g.executor.submit(
276-
cleanup_modules, server['modules'], g.options['debug']
267+
cleanup_modules,
268+
args=(server['modules'], g.options['debug'])
277269
)
278270
await server['response'].join()
279271
server['modules'].clear()
@@ -285,9 +277,8 @@ async def _on_request(self, **server):
285277
raise Forbidden(f'Disallowed file extension: {ext}')
286278

287279
logger.info('%s -> %s: %s', path, mime_types[ext], module_path)
288-
await response.sendfile(
289-
module_path, content_type=mime_types[ext], executor=g.executor
290-
)
280+
await response.sendfile(module_path, content_type=mime_types[ext])
281+
291282
# exit middleware without closing the connection
292283
return True
293284

httpout/response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
class HTTPResponse:
1111
def __init__(self, response):
1212
self.response = response
13-
self.loop = response.request.protocol.loop
14-
self.logger = response.request.protocol.logger
13+
self.loop = response.request.server.loop
14+
self.logger = response.request.server.logger
1515
self.tasks = set()
1616

1717
def __getattr__(self, name):

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ description = """\
1414
"""
1515
requires-python = '>=3.7'
1616
dependencies = [
17-
'awaiter',
1817
'tremolo>=0.2.0',
1918
]
2019
license = { text = 'MIT License' }

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
awaiter
2-
tremolo>=0.2.0
1+
tremolo>=0.4.0

0 commit comments

Comments
 (0)