Skip to content

Commit

Permalink
Wrap m.intentional_deadlock in a Python function, for `ForkingPickler…
Browse files Browse the repository at this point in the history
…` compatibility.

```
>       ForkingPickler(file, protocol).dump(obj)
E       TypeError: cannot pickle 'PyCapsule' object
```

Observed with all Windows builds including mingw but not PyPy, and macos-latest with Python 3.9, 3.10, 3.11 but not 3.6.
  • Loading branch information
rwgk committed Oct 30, 2022
1 parent ea8b132 commit 4c19a9a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/test_gil_scoped.py
Expand Up @@ -138,7 +138,11 @@ def test_all_basic_tests_completeness():
assert len(ALL_BASIC_TESTS) == num_found


ALL_BASIC_TESTS_PLUS_INTENTIONAL_DEADLOCK = ALL_BASIC_TESTS + (m.intentional_deadlock,)
def _intentional_deadlock():
m.intentional_deadlock()


ALL_BASIC_TESTS_PLUS_INTENTIONAL_DEADLOCK = ALL_BASIC_TESTS + (_intentional_deadlock,)


def _run_in_process(target, *args, **kwargs):
Expand All @@ -147,7 +151,7 @@ def _run_in_process(target, *args, **kwargs):
else:
test_fn = args[0]
# Do not need to wait much, 10s should be more than enough.
timeout = 0.1 if test_fn is m.intentional_deadlock else 10
timeout = 0.1 if test_fn is _intentional_deadlock else 10
process = multiprocessing.Process(target=target, args=args, kwargs=kwargs)
process.daemon = True
try:
Expand All @@ -164,7 +168,7 @@ def _run_in_process(target, *args, **kwargs):
pytest.skip(
"ThreadSanitizer: starting new threads after multi-threaded fork is not supported."
)
elif test_fn is m.intentional_deadlock:
elif test_fn is _intentional_deadlock:
assert process.exitcode is None
return 0
elif process.exitcode is None:
Expand Down

0 comments on commit 4c19a9a

Please sign in to comment.