Skip to content

Commit a91520f

Browse files
authored
Make Deferred API compatible with Py2 code and devappserver by introducing an environment variable (#42)
1 parent a11e8b7 commit a91520f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/google/appengine/api/app_identity/_metadata_server.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
and enhanced to support explicit oauth2 scopes.
2222
"""
2323

24-
25-
2624
import os
2725
import time
2826
from typing import List, Optional, Text, Tuple

src/google/appengine/ext/deferred/deferred.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def hello_world():
110110

111111
import http
112112
import logging
113+
import os
113114
import pickle
114115
import types
115116
from google.appengine.api import taskqueue
@@ -264,7 +265,11 @@ def serialize(obj, *args, **kwargs):
264265
A serialized representation of the callable.
265266
"""
266267
curried = _curry_callable(obj, *args, **kwargs)
267-
return pickle.dumps(curried, protocol=pickle.HIGHEST_PROTOCOL)
268+
if os.environ.get("DEFERRED_USE_CROSS_COMPATIBLE_PICKLE_PROTOCOL", False):
269+
protocol = 0
270+
else:
271+
protocol = pickle.HIGHEST_PROTOCOL
272+
return pickle.dumps(curried, protocol)
268273

269274

270275
def defer(obj, *args, **kwargs):

0 commit comments

Comments
 (0)