Skip to content

Commit 38ba744

Browse files
authored
Merge branch 'master' into use-single-internal-header
2 parents 189e09f + 4c5303f commit 38ba744

File tree

15 files changed

+318
-144
lines changed

15 files changed

+318
-144
lines changed

.github/workflows/all_checks_pass.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/changelog.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/memory_leak.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 142 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,151 @@
11
name: Tests
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
paths:
8-
- 'tests/**'
9-
- 'src/**'
10-
- '.github/workflows/tests.yml'
11-
pull_request:
12-
branches:
13-
- master
14-
paths:
15-
- 'tests/**'
16-
- 'src/**'
17-
- '.github/workflows/tests.yml'
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types:
9+
- "opened"
10+
- "reopened"
11+
- "synchronize"
1812

1913
concurrency:
20-
group: test-${{ github.head_ref }}
21-
cancel-in-progress: true
14+
group: test-${{ github.head_ref }}
15+
cancel-in-progress: true
2216

2317
env:
24-
PYTHONUNBUFFERED: "1"
25-
FORCE_COLOR: "1"
26-
PYTHONIOENCODING: "utf8"
27-
PYAWAITABLE_OPTIMIZED: 1
18+
PYTHONUNBUFFERED: "1"
19+
FORCE_COLOR: "1"
20+
PYTHONIOENCODING: "utf8"
21+
PYAWAITABLE_OPTIMIZED: 1
2822

2923
jobs:
30-
run-tests:
31-
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
32-
runs-on: ${{ matrix.os }}
33-
strategy:
34-
fail-fast: false
35-
matrix:
36-
os: [ubuntu-latest, windows-latest, macos-latest]
37-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
38-
39-
steps:
40-
- uses: actions/checkout@v2
41-
42-
- name: Set up Python ${{ matrix.python-version }}
43-
uses: actions/setup-python@v2
44-
with:
45-
python-version: ${{ matrix.python-version }}
46-
47-
- name: Install Pytest
48-
run: pip install pytest pytest-asyncio typing_extensions
49-
50-
- name: Build PyAwaitable
51-
run: pip install .
52-
53-
- name: Build PyAwaitable Test Package
54-
run: pip install setuptools wheel && pip install ./tests/extension/ --no-build-isolation
55-
56-
- name: Run tests
57-
run: pytest -W error
24+
changes:
25+
name: Check for changed files
26+
runs-on: ubuntu-latest
27+
outputs:
28+
source: ${{ steps.filter.outputs.source }}
29+
csource: ${{ steps.filter.outputs.csource }}
30+
steps:
31+
- uses: actions/checkout@v2
32+
- uses: dorny/paths-filter@v3
33+
id: filter
34+
with:
35+
filters: |
36+
source:
37+
- 'src/**'
38+
csource:
39+
- 'src/_pyawaitable/**'
40+
41+
run-tests:
42+
needs: changes
43+
if: ${{ needs.changes.outputs.source == 'true' }}
44+
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
45+
runs-on: ${{ matrix.os }}
46+
strategy:
47+
fail-fast: true
48+
matrix:
49+
os: [ubuntu-latest, windows-latest, macos-latest]
50+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
51+
steps:
52+
- uses: actions/checkout@v2
53+
54+
- name: Set up Python ${{ matrix.python-version }}
55+
uses: actions/setup-python@v2
56+
with:
57+
python-version: ${{ matrix.python-version }}
58+
59+
- name: Install Pytest
60+
run: pip install pytest pytest-asyncio typing_extensions
61+
62+
- name: Build PyAwaitable
63+
run: pip install .
64+
65+
- name: Build PyAwaitable Test Package
66+
run: pip install setuptools wheel && pip install ./tests/extension/ --no-build-isolation
67+
68+
- name: Run tests
69+
run: pytest -W error
70+
71+
memory-errors:
72+
needs:
73+
- changes
74+
- run-tests
75+
if: ${{ needs.changes.outputs.csource == 'true' }}
76+
name: Check for memory errors
77+
runs-on: ubuntu-latest
78+
env:
79+
PYTHONMALLOC: malloc
80+
steps:
81+
- uses: actions/checkout@v2
82+
83+
- name: Set up Python 3.12
84+
uses: actions/setup-python@v2
85+
with:
86+
python-version: 3.12
87+
88+
- name: Install Pytest
89+
run: |
90+
pip install pytest pytest-asyncio pytest-memray typing_extensions
91+
shell: bash
92+
93+
- name: Build PyAwaitable
94+
run: pip install .
95+
96+
- name: Build PyAwaitable Test Package
97+
run: pip install setuptools wheel && pip install tests/extension/ --no-build-isolation
98+
99+
- name: Install Valgrind
100+
run: sudo apt-get update && sudo apt-get -y install valgrind
101+
102+
- name: Run tests with Valgrind
103+
run: valgrind --suppressions=valgrind-python.supp --error-exitcode=1 pytest -x
104+
105+
memory-leaks:
106+
needs:
107+
- changes
108+
- memory-errors
109+
if: ${{ needs.changes.outputs.csource == 'true' }}
110+
name: Check for memory leaks
111+
runs-on: ubuntu-latest
112+
env:
113+
PYTHONMALLOC: malloc
114+
steps:
115+
- uses: actions/checkout@v2
116+
117+
- name: Set up Python 3.12
118+
uses: actions/setup-python@v2
119+
with:
120+
python-version: 3.12
121+
122+
- name: Install Pytest
123+
run: |
124+
pip install pytest pytest-asyncio pytest-memray typing_extensions
125+
shell: bash
126+
127+
- name: Build PyAwaitable
128+
run: pip install .
129+
130+
- name: Build PyAwaitable Test Package
131+
run: pip install setuptools wheel && pip install tests/extension/ --no-build-isolation
132+
133+
- name: Run tests with Memray tracking
134+
run: pytest --enable-leak-tracking -W error --stacks=50 --native
135+
136+
tests-pass:
137+
runs-on: ubuntu-latest
138+
name: All tests passed
139+
if: always()
140+
141+
needs:
142+
- run-tests
143+
- memory-errors
144+
- memory-leaks
145+
146+
steps:
147+
- name: Check whether all tests passed
148+
uses: re-actors/alls-green@release/v1
149+
with:
150+
jobs: ${{ toJSON(needs) }}
151+
allowed-skips: ${{ toJSON(needs) }}

.github/workflows/triage.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Triage
2+
on:
3+
pull_request:
4+
types:
5+
- "opened"
6+
- "reopened"
7+
- "synchronize"
8+
- "labeled"
9+
- "unlabeled"
10+
11+
jobs:
12+
changelog_check:
13+
runs-on: ubuntu-latest
14+
name: Check for changelog updates
15+
steps:
16+
- name: "Check if the source directory was changed"
17+
uses: dorny/paths-filter@v3
18+
id: changes
19+
with:
20+
filters: |
21+
src:
22+
- 'src/**'
23+
24+
- name: "Check for changelog updates"
25+
if: steps.changes.outputs.src == 'true'
26+
uses: brettcannon/check-for-changed-files@v1
27+
with:
28+
file-pattern: |
29+
CHANGELOG.md
30+
skip-label: "skip changelog"
31+
failure-message: "Missing a CHANGELOG.md update; please add one or apply the ${skip-label} label to the pull request"
32+
33+
tests_check:
34+
runs-on: ubuntu-latest
35+
name: Check for updated tests
36+
steps:
37+
- name: "Check if the source directory was changed"
38+
uses: dorny/paths-filter@v3
39+
id: changes
40+
with:
41+
filters: |
42+
src:
43+
- 'src/**'
44+
45+
- name: "Check for test updates"
46+
if: steps.changes.outputs.src == 'true'
47+
uses: brettcannon/check-for-changed-files@v1
48+
with:
49+
file-pattern: |
50+
tests/*
51+
skip-label: "skip tests"
52+
failure-message: "Missing unit tests; please add some or apply the ${skip-label} label to the pull request"
53+
54+
all_green:
55+
runs-on: ubuntu-latest
56+
name: PR has no missing information
57+
if: always()
58+
59+
needs:
60+
- changelog_check
61+
- tests_check
62+
63+
steps:
64+
- name: Check whether jobs passed
65+
uses: re-actors/alls-green@release/v1
66+
with:
67+
jobs: ${{ toJSON(needs) }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Objects returned by a PyAwaitable object's `__await__` are now garbage collected (*i.e.*, they don't leak with rare circular references).
1313
- Removed limit on number of stored callbacks or values.
1414
- Switched some user-error messages to `RuntimeError` instead of `SystemError`.
15+
- Added `PyAwaitable_DeferAwait` for executing code when the awaitable object is called by the event loop.
1516

1617
## [1.3.0] - 2024-10-26
1718

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
[![Build Wheels](https://github.com/ZeroIntensity/pyawaitable/actions/workflows/build.yml/badge.svg)](https://github.com/ZeroIntensity/pyawaitable/actions/workflows/build.yml)
66
![Tests](https://github.com/ZeroIntensity/pyawaitable/actions/workflows/tests.yml/badge.svg)
7-
![Memory Leak](https://github.com/ZeroIntensity/pyawaitable/actions/workflows/memory_leak.yml/badge.svg)
87

98
- [Docs](https://awaitable.zintensity.dev)
109
- [Source](https://github.com/ZeroIntensity/pyawaitable)

include/pyawaitable/awaitableobject.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
typedef int (*awaitcallback)(PyObject *, PyObject *);
55
typedef int (*awaitcallback_err)(PyObject *, PyObject *);
6+
typedef int (*defer_callback)(PyObject *);
67

78
typedef struct _pyawaitable_callback
89
{
@@ -47,6 +48,8 @@ int pyawaitable_await_impl(
4748
awaitcallback_err err
4849
);
4950

51+
int pyawaitable_defer_await_impl(PyObject *aw, defer_callback cb);
52+
5053
void pyawaitable_cancel_impl(PyObject *aw);
5154

5255
PyObject *

0 commit comments

Comments
 (0)