Browse Source

First try on cross python 2 and 3 compatible code

opensearch
Roi Rav-Hon 8 years ago
parent
commit
1fe6be90f7
4 changed files with 13 additions and 4 deletions
  1. +1
    -1
      .travis.yml
  2. +5
    -2
      logzio/sender.py
  3. +3
    -0
      setup.py
  4. +4
    -1
      tests/mockLogzioListener/listener.py

+ 1
- 1
.travis.yml View File

@ -7,6 +7,6 @@ python:
- "3.4" - "3.4"
install: install:
- pip install requests
- pip install requests future
script: py.test script: py.test

+ 5
- 2
logzio/sender.py View File

@ -4,9 +4,12 @@ import requests
import json import json
from threading import Thread, enumerate from threading import Thread, enumerate
from datetime import datetime from datetime import datetime
from Queue import Queue
from time import sleep from time import sleep
if sys.version[0] == '2':
import Queue as queue
else:
import queue as queue
MAX_BULK_SIZE_IN_BYTES = 3 * 1024 * 1024 # 3 MB MAX_BULK_SIZE_IN_BYTES = 3 * 1024 * 1024 # 3 MB
@ -29,7 +32,7 @@ class LogzioSender:
self.is_main_thread_active = lambda: any((i.name == "MainThread") and i.is_alive() for i in enumerate()) self.is_main_thread_active = lambda: any((i.name == "MainThread") and i.is_alive() for i in enumerate())
# Create a queue to hold logs # Create a queue to hold logs
self.queue = Queue()
self.queue = queue.Queue()
self.sending_thread = Thread(target=self._drain_queue) self.sending_thread = Thread(target=self._drain_queue)
self.sending_thread.daemon = False self.sending_thread.daemon = False


+ 3
- 0
setup.py View File

@ -15,6 +15,9 @@ setup(
install_requires=[ install_requires=[
"requests" "requests"
], ],
test_requires=[
"future"
],
include_package_data=True, include_package_data=True,
classifiers=[ classifiers=[
'Development Status :: 5 - Production/Stable', 'Development Status :: 5 - Production/Stable',


+ 4
- 1
tests/mockLogzioListener/listener.py View File

@ -1,5 +1,8 @@
# noinspection PyUnresolvedReferences
import future
import socket import socket
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from http.server import BaseHTTPRequestHandler, HTTPServer
from threading import Thread from threading import Thread
from .logsList import logs_list from .logsList import logs_list
from .persistentFlags import persistent_flags from .persistentFlags import persistent_flags


Loading…
Cancel
Save