Skip to content

Commit

Permalink
(feat) added support for custom content type
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 committed Aug 18, 2016
1 parent f960c0a commit 0fd931a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions slacker/geventbackend.py
Expand Up @@ -76,11 +76,9 @@ def send(self, request, timeout):
raise RuntimeError("Timeout")
## reconnect
gevent.spawn(self._reconnect)
print 1
except:
## reconnect
gevent.spawn(self._reconnect)
print 2

return cb

Expand All @@ -94,18 +92,19 @@ def close(self):
self.connect_lock.clear()

class Client(object):
def __init__(self, addr, timeout=10):
def __init__(self, addr, timeout=10, content_type=PROTOCOL_CONTENT_TYPE_CLJ):
self.timeout = timeout
conn = Connection(addr)
#conn.connect()
self.conn = conn
self.started = True
self.content_type = content_type

def call(self, fname, args):
if not self.started:
raise RuntimeError("Client closed.")

req = SlackerRequest(PROTOCOL_CONTENT_TYPE_CLJ, fname, args)
req = SlackerRequest(self.content_type, fname, args)
req.serialize()
cb = self.conn.send(req, self.timeout)
try:
Expand Down

0 comments on commit 0fd931a

Please sign in to comment.