Skip to content

Commit

Permalink
Optionally use pickle5 (#3849)
Browse files Browse the repository at this point in the history
Optionally use pickle5
  • Loading branch information
jakirkham authored Jul 10, 2020
1 parent a228e69 commit a8a7586
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 7 deletions.
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

0 comments on commit a8a7586

Please sign in to comment.