Skip to content

Instantly share code, notes, and snippets.

@akx
Created June 21, 2016 16:20
Show Gist options
  • Select an option

  • Save akx/388f1d9b5fa60c96d5c8f834be1005db to your computer and use it in GitHub Desktop.

Select an option

Save akx/388f1d9b5fa60c96d5c8f834be1005db to your computer and use it in GitHub Desktop.
class FireAndForgetThreadedHTTPTransport(AsyncTransport, HTTPTransport):
scheme = ['http', 'https', 'faf+http', 'faf+https']
def send_sync(self, data, headers, success_cb, failure_cb):
try:
super(ThreadedHTTPTransport, self).send(data, headers)
except Exception as e:
failure_cb(e)
else:
success_cb()
def async_send(self, data, headers, success_cb, failure_cb):
threading.Thread(
target=self.send_sync,
args=(data, headers, success_cb, failure_cb)
).start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment