Skip to content

Commit 10b0bf2

Browse files
committed
Manual sync: v0.1a2.
1 parent b8ac36a commit 10b0bf2

File tree

8 files changed

+22
-9
lines changed

8 files changed

+22
-9
lines changed

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ global-exclude onesdk_shared.*
44
global-exclude *.pyc
55
global-exclude *.pyo
66
global-exclude __pycache__/*
7+
include MANIFEST.in
8+
include README.md

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def iad_add_directive_header(self, sig):
110110
# Add any paths that contain custom static files (such as style sheets) here,
111111
# relative to this directory. They are copied after the builtin static files,
112112
# so a file named "default.css" will overwrite the builtin "default.css".
113-
html_static_path = ['_static']
113+
#html_static_path = ['_static']
114114

115115
# Custom sidebar templates, must be a dictionary that maps document names
116116
# to template names.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def copy_extensions_to_source(self):
153153
self.__base.copy_extensions_to_source(self)
154154

155155
build_py = self.get_finalized_command('build_py')
156-
src_filename = self.get_dll_output_path()
156+
src_filename = get_dll_input_path(self.plat_name)
157157
package = 'oneagent._impl.native'
158158
package_dir = build_py.get_package_dir(package)
159159
dest_filename = path.join(package_dir, path.basename(src_filename))

src/oneagent/_impl/native/sdkctypesiface.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def _initfn(self, name, args, ret, public=True):
134134
def __init__(self, libname):
135135
self._log_cb = None
136136
self._diag_cb = None
137+
self._py_diag_cb = None
137138

138139
self._dll = ctypes.WinDLL(libname) if WIN32 else ctypes.CDLL(libname)
139140

@@ -403,14 +404,19 @@ def agent_set_logging_callback(self, callback):
403404
self._agent_set_logging_callback(
404405
ctypes.cast(None, agent_logging_callback_t))
405406
self._diag_cb = None
407+
self._py_diag_cb = None
406408
else:
409+
410+
@wraps(callback)
407411
def cb_wrapper(msg):
408412
if isinstance(msg, six.binary_type):
409413
msg = u8_to_str(msg)
410414
return callback(msg)
415+
411416
c_cb = agent_logging_callback_t(cb_wrapper)
412417
self._agent_set_logging_callback(c_cb)
413418
self._diag_cb = c_cb
419+
self._py_diag_cb = cb_wrapper
414420

415421
def __del__(self):
416422
# __del__ is also called when __init__ fails, so safeguard against that
@@ -420,9 +426,7 @@ def __del__(self):
420426
self.stub_set_logging_callback(None)
421427

422428
def agent_get_logging_callback(self):
423-
if self._diag_cb:
424-
return self._diag_cb.value
425-
return None
429+
return self._py_diag_cb
426430

427431
def tracer_get_outgoing_tag(self, tracer, use_byte_tag=False):
428432
tagsz = ctypes.c_size_t()

test/sdk_diag_prog.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import print_function
44

55
import sys
6+
import gc
67

78
import oneagent
89
from oneagent._impl import six
@@ -19,9 +20,15 @@ def diag_cb(msg):
1920
try:
2021
sdk.set_diagnostic_callback(diag_cb)
2122
sdk.create_database_info(None, None, onesdk.Channel(0))
23+
gc.collect()
24+
gc.collect()
25+
gc.collect()
2226
print(call_msg)
2327
n_msgs = len(call_msg)
24-
assert n_msgs >= 1
28+
29+
# Database name must not be null (from CSDK), leaked db info handle
30+
assert n_msgs == 2
31+
2532
assert all(isinstance(m, six.text_type) for m in call_msg)
2633
sdk.set_diagnostic_callback(None)
2734
sdk.create_database_info(None, None, onesdk.Channel(0))

test/test_init_public_sdk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def main():
8888

8989
if 'tryinit' in flags:
9090
try:
91-
init_result = oneagent.try_init()
91+
init_result = oneagent.try_init(['loglevelsdk=finest'])
9292
except ImportError:
9393
if 'nonull' in flags:
9494
print('ABORTED.')

test/urllib_sandbox_py3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from oneagent.sdk import SDK
55

66
def bench():
7-
with SDK.get().trace_incoming_remote_call('a', 'b', 'c').start():
7+
with SDK.get().trace_incoming_remote_call('a', 'b', 'c'):
88
tdf = 0
99
t_tot = 0
1010
t_inner = None

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ envlist = {py27,py36}-{lint,test}, docs
55
setenv =
66
test: PYTHONDONTWRITEBYTECODE = 1
77
PYTHONPATH = test-util-src
8-
passenv = DT_HOME
8+
passenv = DT_AGENTLIBRARY
99
commands =
1010
test: pytest test {posargs}
1111
lint: pylint oneagent

0 commit comments

Comments
 (0)