Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
cluster_type: slurm
container: slurmctld
- python: "3.7"
- python: "3.8"
- python: "3.10"
env:
IPP_CONTROLLER_IP: "*"
- python: "3.9"
Expand All @@ -46,6 +46,7 @@ jobs:
runs_on: windows-2019
- python: "3.9"
runs_on: macos-10.15
- python: "3.11.0-beta.3"

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -120,7 +121,12 @@ jobs:

- name: Install Python dependencies
run: |
pip install --pre --upgrade ipyparallel[test] distributed joblib codecov
pip install --pre --upgrade ipyparallel[test] codecov

- name: Install extra Python packages
if: ${{ ! startsWith(matrix.python, '3.11') }}
run: |
pip install distributed joblib
pip install --only-binary :all: matplotlib || echo "no matplotlib"

- name: Show environment
Expand Down
5 changes: 4 additions & 1 deletion ipyparallel/engine/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ def do_apply(self, content, bufs, msg_id, reply_metadata):
except BaseException as e:
# invoke IPython traceback formatting
# this sends the 'error' message
shell.showtraceback()
try:
shell.showtraceback()
except Exception as tb_error:
self.log.error(f"Failed to show traceback for {e}: {tb_error}")

try:
str_evalue = str(e)
Expand Down
69 changes: 43 additions & 26 deletions ipyparallel/serialize/codeutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,58 @@
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import copyreg
import inspect
import sys
import types

try:
import copyreg # Py 3
except ImportError:
import copy_reg as copyreg # Py 2


def code_ctor(*args):
return types.CodeType(*args)


def reduce_code(co):
args = [
co.co_argcount,
co.co_nlocals,
co.co_stacksize,
co.co_flags,
co.co_code,
co.co_consts,
co.co_names,
co.co_varnames,
co.co_filename,
co.co_name,
co.co_firstlineno,
co.co_lnotab,
co.co_freevars,
co.co_cellvars,
# map CodeType constructor args to code co_ attribute names
# (they _almost_ all match, and new ones probably will)
_code_attr_map = {
"codestring": "code",
"constants": "consts",
}
# pass every supported arg to the code constructor
# this should be more forward-compatible
if sys.version_info >= (3, 10):
_code_attr_names = tuple(
_code_attr_map.get(name, name)
for name, param in inspect.signature(types.CodeType).parameters.items()
if param.POSITIONAL_ONLY or param.POSITIONAL_OR_KEYWORD
)
else:
# can't inspect types.CodeType on Python < 3.10
_code_attr_names = [
"argcount",
"kwonlyargcount",
"nlocals",
"stacksize",
"flags",
"code",
"consts",
"names",
"varnames",
"filename",
"name",
"firstlineno",
"lnotab",
"freevars",
"cellvars",
]
if sys.version_info[0] >= 3:
args.insert(1, co.co_kwonlyargcount)
if sys.version_info > (3, 8):
args.insert(1, co.co_posonlyargcount)
return code_ctor, tuple(args)
if hasattr(types.CodeType, "co_posonlyargcount"):
_code_attr_names.insert(1, "posonlyargcount")

_code_attr_names = tuple(_code_attr_names)


def reduce_code(obj):
"""codeobject reducer"""
return code_ctor, tuple(getattr(obj, f'co_{name}') for name in _code_attr_names)


copyreg.pickle(types.CodeType, reduce_code)
3 changes: 2 additions & 1 deletion ipyparallel/tests/clienttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ def _sigalarm(sig, frame):
self.engines = []

def tearDown(self):
self.client[:].use_pickle()
if len(self.client):
self.client[:].use_pickle()

# self.client.clear(block=True)
# close fds:
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ testpaths = [
"ipyparallel/tests"
]
filterwarnings = [
"error",
"error:::ipy*",
"error:::jupyter*",
"ignore:unclosed event loop:ResourceWarning",
"ignore:unclosed socket <zmq.Socket:ResourceWarning",
"ignore:unclosed <socket.socket:ResourceWarning",
Expand Down