Skip to content

Commit

Permalink
Make Deferred API compatible with Py2 code and devappserver by introd…
Browse files Browse the repository at this point in the history
…ucing an environment variable (#42)
  • Loading branch information
shreejad authored Nov 18, 2021
1 parent a11e8b7 commit a91520f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/google/appengine/api/app_identity/_metadata_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
and enhanced to support explicit oauth2 scopes.
"""



import os
import time
from typing import List, Optional, Text, Tuple
Expand Down
7 changes: 6 additions & 1 deletion src/google/appengine/ext/deferred/deferred.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def hello_world():

import http
import logging
import os
import pickle
import types
from google.appengine.api import taskqueue
Expand Down Expand Up @@ -264,7 +265,11 @@ def serialize(obj, *args, **kwargs):
A serialized representation of the callable.
"""
curried = _curry_callable(obj, *args, **kwargs)
return pickle.dumps(curried, protocol=pickle.HIGHEST_PROTOCOL)
if os.environ.get("DEFERRED_USE_CROSS_COMPATIBLE_PICKLE_PROTOCOL", False):
protocol = 0
else:
protocol = pickle.HIGHEST_PROTOCOL
return pickle.dumps(curried, protocol)


def defer(obj, *args, **kwargs):
Expand Down

0 comments on commit a91520f

Please sign in to comment.