Permalink
Browse files

Starting ProxyRepository and Proxy with an IO loop

  • Loading branch information...
1 parent 244f19d commit cb45f9f657fbb2ccbaf83f5d4398928d04d556e9 @diogobaeder committed Mar 25, 2013
Showing with 15 additions and 7 deletions.
  1. +5 −2 Makefile
  2. +1 −1 memcrashed/handlers/binary.py
  3. +1 −1 memcrashed/handlers/text.py
  4. +6 −2 memcrashed/proxy.py
  5. +2 −1 tests/test_proxy.py
View
@@ -22,5 +22,8 @@ lint:
@flake8 . --ignore=E501
install:
- pip install -r $(MAIN_REQUIREMENTS) --use-mirrors
- pip install -r requirements-py$(PYTHON_MAJOR_VERSION).txt --use-mirrors
+ @echo Installing dependencies...
+ @pip install -r $(MAIN_REQUIREMENTS) --use-mirrors
+ -@[ -f $(EXTENDED_REQUIREMENTS) ] && pip install -r $(EXTENDED_REQUIREMENTS) --use-mirrors || \
+ echo File "$(EXTENDED_REQUIREMENTS)" doesn\'t exist, skipping version-specific packages
+ @echo Finished installing dependencies.
@@ -36,7 +36,7 @@ class BinaryProtocolHandler(object):
def __init__(self, io_loop):
self.io_loop = io_loop
self.parser = BinaryParser()
- self.pool_repository = ProxyRepository()
+ self.pool_repository = ProxyRepository(self.io_loop)
@gen.engine
def process(self, client_stream, backend_stream, callback):
@@ -15,7 +15,7 @@ class TextProtocolHandler(object):
def __init__(self, io_loop):
self.io_loop = io_loop
self.parser = TextParser()
- self.pool_repository = ProxyRepository()
+ self.pool_repository = ProxyRepository(self.io_loop)
@gen.engine
def process(self, client_stream, backend_stream, callback):
View
@@ -1,8 +1,12 @@
class ProxyRepository(object):
+ def __init__(self, io_loop):
+ self.io_loop = io_loop
+
def proxy_for_key(self, key):
- return Proxy(key)
+ return Proxy(key, self.io_loop)
class Proxy(object):
- def __init__(self, key):
+ def __init__(self, key, io_loop):
self.key = key
+ self.io_loop = io_loop
View
@@ -7,9 +7,10 @@
class ProxyRepositoryTest(ServerTestCase):
@istest
def gets_proxy_for_key(self):
- repository = ProxyRepository()
+ repository = ProxyRepository(self.io_loop)
proxy = repository.proxy_for_key('foo')
self.assertIsInstance(proxy, Proxy)
self.assertEqual(proxy.key, 'foo')
+ self.assertEqual(proxy.io_loop, self.io_loop)

0 comments on commit cb45f9f

Please sign in to comment.