cognite-sdk-python icon indicating copy to clipboard operation
cognite-sdk-python copied to clipboard

Add callback to global_config to allow tracking of one's own SDK usage

Open haakonvt opened this issue 1 year ago • 5 comments

DRAFT

Ref. edm-pipeline debug discussion: @spex66 @thorkildcognite

Checklist:

  • [ ] Tests added/updated.
  • [ ] Documentation updated. Documentation is generated from docstrings - these must be updated according to your change. If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.
  • [ ] Changelog updated in CHANGELOG.md.
  • [ ] Version bumped. If triggering a new release is desired, bump the version number in _version.py and pyproject.toml per semantic versioning.

haakonvt avatar Nov 04 '23 21:11 haakonvt

Not run it yet, but expected code consolidating counters across threads/processes?

Or does it require handling concurrency on callback side?

Parallelism still confuses me every time :)

spex66 avatar Nov 04 '23 23:11 spex66

Accidentally clicked close... 👀

haakonvt avatar Nov 05 '23 12:11 haakonvt

Not run it yet, but expected code consolidating counters across threads/processes?

@spex66 The callback will be called by the different threads executing the requests (the SDK only uses threading as a means of concurrency). In the two examples given in the docstring, they would all write to the same object, which is totally fine (GIL + ordering doesn't matter).

Do you have a usage pattern in mind that you're afraid might have a race condition?

haakonvt avatar Nov 05 '23 12:11 haakonvt

@spex66 do you need this feature or should we put it on hold?

haakonvt avatar Nov 29 '23 13:11 haakonvt

Ok hold pls, and I need to set a reminder to look into it .. later

spex66 avatar Nov 29 '23 13:11 spex66