Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally use pickle5 #3849

Merged
merged 9 commits into from
Jul 10, 2020
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
6 changes: 4 additions & 2 deletions continuous_integration/travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ if [[ $PYTHON == 3.6 ]]; then
conda install -c conda-forge -c defaults contextvars
fi

# stacktrace is not currently avaiable for Python 3.8.
# Remove the version check block below when it is avaiable.
if [[ $PYTHON != 3.8 ]]; then
# Install backport package for pickle protocol 5 support
conda install -c conda-forge -c defaults 'pickle5>=0.0.11'
# stacktrace is not currently avaiable for Python 3.8.
# Remove the version check block below when it is avaiable.
# For low-level profiler, install libunwind and stacktrace from conda-forge
# For stacktrace we use --no-deps to avoid upgrade of python
conda install -c conda-forge -c defaults libunwind
Expand Down
10 changes: 9 additions & 1 deletion distributed/protocol/pickle.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import logging
import pickle
import sys

import cloudpickle

if sys.version_info < (3, 8):
try:
import pickle5 as pickle
except ImportError:
import pickle
else:
import pickle


HIGHEST_PROTOCOL = pickle.HIGHEST_PROTOCOL

Expand Down
9 changes: 8 additions & 1 deletion distributed/protocol/tests/test_pickle.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from functools import partial
import gc
from operator import add
import pickle
import weakref
import sys

Expand All @@ -10,6 +9,14 @@
from distributed.protocol import deserialize, serialize
from distributed.protocol.pickle import HIGHEST_PROTOCOL, dumps, loads

if sys.version_info < (3, 8):
try:
import pickle5 as pickle
except ImportError:
import pickle
else:
import pickle


def test_pickle_data():
data = [1, b"123", "123", [123], {}, set()]
Expand Down
10 changes: 9 additions & 1 deletion distributed/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from numbers import Number
import operator
import os
import pickle
import sys
import random
import warnings
import weakref
Expand Down Expand Up @@ -86,6 +86,14 @@
from .stealing import WorkStealing
from .variable import VariableExtension

if sys.version_info < (3, 8):
try:
import pickle5 as pickle
except ImportError:
import pickle
else:
import pickle


logger = logging.getLogger(__name__)

Expand Down
9 changes: 8 additions & 1 deletion distributed/tests/test_scheduler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
import json
import logging
import pickle
import operator
import re
import sys
Expand Down Expand Up @@ -42,6 +41,14 @@
from distributed.utils_test import loop, nodebug # noqa: F401
from dask.compatibility import apply

if sys.version_info < (3, 8):
try:
import pickle5 as pickle
except ImportError:
import pickle
else:
import pickle


alice = "alice:1234"
bob = "bob:1234"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
click >= 6.6
cloudpickle >= 1.3.0
cloudpickle >= 1.5.0
contextvars;python_version<'3.7'
dask >= 2.9.0
msgpack >= 0.6.0
Expand Down