Skip to content
This repository has been archived by the owner on Apr 18, 2018. It is now read-only.

fix some bug #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions gearman/client_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ def recv_job_created(self, job_handle):

def recv_work_data(self, job_handle, data):
# Queue a WORK_DATA update
current_request = self.handle_to_request_map[job_handle]
try:
current_request = self.handle_to_request_map[job_handle]
except KeyError:
return False

self._assert_request_state(current_request, JOB_CREATED)

current_request.data_updates.append(self.decode_data(data))
Expand All @@ -87,7 +91,11 @@ def recv_work_data(self, job_handle, data):

def recv_work_warning(self, job_handle, data):
# Queue a WORK_WARNING update
current_request = self.handle_to_request_map[job_handle]
try:
current_request = self.handle_to_request_map[job_handle]
except KeyError:
return False

self._assert_request_state(current_request, JOB_CREATED)

current_request.warning_updates.append(self.decode_data(data))
Expand All @@ -96,7 +104,11 @@ def recv_work_warning(self, job_handle, data):

def recv_work_status(self, job_handle, numerator, denominator):
# Queue a WORK_STATUS update
current_request = self.handle_to_request_map[job_handle]
try:
current_request = self.handle_to_request_map[job_handle]
except KeyError:
return False

self._assert_request_state(current_request, JOB_CREATED)

# The protocol spec is ambiguous as to what type the numerator and denominator is...
Expand All @@ -113,7 +125,11 @@ def recv_work_status(self, job_handle, numerator, denominator):

def recv_work_complete(self, job_handle, data):
# Update the state of our request and store our returned result
current_request = self.handle_to_request_map[job_handle]
try:
current_request = self.handle_to_request_map[job_handle]
except KeyError:
return False

self._assert_request_state(current_request, JOB_CREATED)

current_request.result = self.decode_data(data)
Expand All @@ -123,7 +139,11 @@ def recv_work_complete(self, job_handle, data):

def recv_work_fail(self, job_handle):
# Update the state of our request and mark this job as failed
current_request = self.handle_to_request_map[job_handle]
try:
current_request = self.handle_to_request_map[job_handle]
except KeyError:
return False

self._assert_request_state(current_request, JOB_CREATED)

current_request.state = JOB_FAILED
Expand All @@ -134,7 +154,11 @@ def recv_work_exception(self, job_handle, data):
# Using GEARMAND_COMMAND_WORK_EXCEPTION is not recommended at time of this writing [2010-02-24]
# http://groups.google.com/group/gearman/browse_thread/thread/5c91acc31bd10688/529e586405ed37fe
#
current_request = self.handle_to_request_map[job_handle]
try:
current_request = self.handle_to_request_map[job_handle]
except KeyError:
return False

self._assert_request_state(current_request, JOB_CREATED)

current_request.exception = self.decode_data(data)
Expand All @@ -143,7 +167,10 @@ def recv_work_exception(self, job_handle, data):

def recv_status_res(self, job_handle, known, running, numerator, denominator):
# If we received a STATUS_RES update about this request, update our known status
current_request = self.handle_to_request_map[job_handle]
try:
current_request = self.handle_to_request_map[job_handle]
except KeyError:
return False

job_known = bool(known == '1')
# Make our status response Python friendly
Expand Down
5 changes: 4 additions & 1 deletion gearman/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ def set_socket(self, current_socket):

current_socket.setblocking(0)
current_socket.settimeout(0.0)
current_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, struct.pack('L', 1))
try:
current_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, struct.pack('L', 1))
except:
current_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, struct.pack('I', 1))
self.gearman_socket = current_socket

def read_command(self):
Expand Down