Skip to content

Commit

Permalink
Moving managedvms/memcache to pymemcache for better python3 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott committed Feb 22, 2016
1 parent 33cd2a9 commit b0182bc
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 20 deletions.
9 changes: 4 additions & 5 deletions managed_vms/memcache/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
import os

from flask import Flask
import memcache
from pymemcache.client.base import Client as MemcacheClient


app = Flask(__name__)


# [START client]
memcache_addr = os.environ.get('MEMCACHE_PORT_11211_TCP_ADDR', 'localhost')
memcache_port = os.environ.get('MEMCACHE_PORT_11211_TCP_PORT', '11211')
memcache_client = memcache.Client([
'{}:{}'.format(memcache_addr, memcache_port)])
memcache_port = os.environ.get('MEMCACHE_PORT_11211_TCP_PORT', 11211)
memcache_client = MemcacheClient((memcache_addr, int(memcache_port)))
# [END client]


Expand All @@ -37,7 +36,7 @@ def index():
if not memcache_client.get('counter'):
memcache_client.set('counter', 0)

value = memcache_client.incr('counter')
value = memcache_client.incr('counter', 1)

return 'Value is {}'.format(value)
# [END example]
Expand Down
6 changes: 3 additions & 3 deletions managed_vms/memcache/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@


def test_index():
main.memcache_client.set('counter', 0)

if main.memcache_client.get('counter') is None:
try:
main.memcache_client.set('counter', 0)
except ConnectionRefusedError:
pytest.skip('Memcache is unavailable.')

main.app.testing = True
Expand Down
2 changes: 1 addition & 1 deletion managed_vms/memcache/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Flask==0.10.1
gunicorn==19.4.5
python-memcached==1.57
pymemcache==1.3.5
6 changes: 5 additions & 1 deletion requirements-py27-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
gcloud==0.10.1
google-api-python-client==1.5.0
oauth2client==2.0.0.post1
requests[security]==2.9.1
beautifulsoup4==4.4.1
coverage==4.1b2
Flask==0.10.1
Expand All @@ -18,7 +22,7 @@ Werkzeug==0.11.4
nose-timer==0.6.0
Flask-SQLAlchemy==2.1
PyMySQL==0.7.1
python-memcached==1.57
pymemcache==1.3.5
PyCrypto==2.6.1
flaky==3.1.0
Django==1.9.2
Expand Down
6 changes: 5 additions & 1 deletion requirements-py34-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
gcloud==0.10.1
google-api-python-client==1.5.0
oauth2client==2.0.0.post1
requests[security]==2.9.1
beautifulsoup4==4.4.1
coverage==4.1b2
Flask==0.10.1
Expand All @@ -18,7 +22,7 @@ Werkzeug==0.11.4
nose-timer==0.6.0
Flask-SQLAlchemy==2.1
PyMySQL==0.7.1
python-memcached==1.57
pymemcache==1.3.5
PyCrypto==2.6.1
flaky==3.1.0
Django==1.9.2
Expand Down
4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

5 changes: 0 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ envlist = pep8, py27, py34, gae
[testenv]
passenv = *
basepython = python2.7
deps =
-rrequirements.txt
examples =
bigquery/api
blog/introduction_to_data_models_in_cloud_datastore
Expand Down Expand Up @@ -38,7 +36,6 @@ commands =

[testenv:py27]
deps =
{[testenv]deps}
-rrequirements-py27-dev.txt
commands =
python scripts/run-tests.py {posargs:{[testenv]examples}}
Expand All @@ -55,7 +52,6 @@ commands =
[testenv:py34]
basepython = python3.4
deps =
{[testenv]deps}
-rrequirements-py34-dev.txt
commands =
python scripts/run-tests.py {posargs:{[testenv]examples}}
Expand All @@ -72,7 +68,6 @@ commands =

[testenv:gae]
deps =
{[testenv]deps}
-rrequirements-py27-dev.txt
examples =
appengine/app_identity/signing
Expand Down

0 comments on commit b0182bc

Please sign in to comment.