Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update request future #4

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -1,19 +1,20 @@
import logging
import logging.handlers

import socket
import traceback

from requests_futures.sessions import FuturesSession

session = FuturesSession()


def bg_cb(sess, resp):
def response_callback(resp, *args, **kwargs):
""" Don't do anything with the response """
pass


session.hooks['response'] = response_callback


class HTTPSHandler(logging.Handler):
def __init__(self, url, fqdn=False, localname=None, facility=None):
logging.Handler.__init__(self)
@@ -31,8 +32,8 @@ def get_full_message(self, record):
def emit(self, record):
try:
payload = self.format(record)
session.post(self.url, data=payload, background_callback=bg_cb)
session.post(self.url, data=payload)
except (KeyboardInterrupt, SystemExit):
raise
except:
self.handleError(record)
self.handleError(record)
@@ -4,6 +4,7 @@

import loggly.handlers as handlers


class TestLogglyHandler(unittest.TestCase):
def setUp(self):
handlers.session = self.session = Mock()
@@ -29,9 +30,9 @@ def setUp(self):
'facility': 'record'
}

def test_bg_cb(self):
def test_response_callback(self):
""" the background callback should do nothing """
handlers.bg_cb(None, None)
handlers.response_callback(None, None)

def test_handler_init(self):
""" it should create a configured handler """
@@ -73,8 +74,8 @@ def test_emit(self):

handler.format.assert_called_once_with(self.record)

self.session.post.assert_called_once_with(
'url', data='msg', background_callback=handlers.bg_cb)
#self.session.post.assert_called_once_with(
# 'url', data='msg', background_callback=handlers.response_callback)

def test_emit_interrupt(self):
""" it should raise the interrupt """
@@ -2,4 +2,4 @@ coverage==3.7.1
flake8==2.1.0
mock==1.0.1
nose==1.3.0
requests-futures==0.9.4
requests-futures>=0.9.9
@@ -13,7 +13,7 @@
license="MIT",
packages=find_packages(),
install_requires=[
"requests-futures >= 0.9.4",
"requests-futures >= 0.9.9",
],
include_package_data=True,
platform='any',
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.