From: erickson Date: Sun, 18 May 2008 23:42:17 +0000 (+0000) Subject: No longer globally setting the network recv_callback handler to None X-Git-Tag: osrf_rel_2_0_1~639 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3c8aa70662a1a5d1d38d06de3e0948d70ddf85c7;p=OpenSRF.git No longer globally setting the network recv_callback handler to None because it clobbers the callbacks of other python clients running in the same within the same process. Now we capture the existing callback and replace it after the request has been processed git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1328 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/python/osrf/http_translator.py b/src/python/osrf/http_translator.py index 44ab735..1a13d44 100644 --- a/src/python/osrf/http_translator.py +++ b/src/python/osrf/http_translator.py @@ -85,11 +85,22 @@ def child_init(req): def handler(req): ''' Create the translator and tell it to process the request. ''' child_init(req) - translator = HTTPTranslator(req) - status = translator.process() - osrf.log.log_debug("translator call resulted in status %d" % int(status)) - if translator.local_xid: - osrf.log.clear_xid() + + # capture the callback handle, clear it, then reset + # it after we've handled the request + handle = osrf.net.get_network_handle() + callback = handle.receive_callback + handle.set_receive_callback(None) + + try: + translator = HTTPTranslator(req) + status = translator.process() + osrf.log.log_debug("translator call resulted in status %d" % int(status)) + if translator.local_xid: + osrf.log.clear_xid() + finally: + handle.receive_callback = callback + return status class HTTPTranslator(object): @@ -126,7 +137,6 @@ class HTTPTranslator(object): self.messages = [] self.complete = False self.handle = osrf.net.get_network_handle() - self.handle.set_receive_callback(None) self.recipient = apreq.headers_in.get(OSRF_HTTP_HEADER_TO) self.service = apreq.headers_in.get(OSRF_HTTP_HEADER_SERVICE)