Skip to main content

No project description provided

Project description

context-goodies

Helper functions to maintain process/thread/coroutine local data in trusted microservices.

Install

pip install context-goodies

You can also "vendor" the module by copying context_goodies.py to your project. There are no pypi dependencies.

Request ID

Call set_current_request_id to set a new request id. If using Django, add context_goodies.context_middleware to MIDDLEWARES to maintain request ids automatically. Note it assumes an internal microservice API and trusted clients.

Logging context

Call update_logging_context to add new data to every log line, eg. update_logging_context(user_id=user_id).

Logging config example

Filter and formatter to log context data added with update_logging_context:

'filters': {
    'extra': {'()': 'context_goodies.ExtraDataFilter'},
},
'formatters': {'verbose': {'format': '[%(name)s][%(levelname)s] %(message)s%(extra)s'}},
'handlers': {
    'console': {
        'level': 'DEBUG',
        'class': 'logging.StreamHandler',
        'formatter': 'verbose',
        'filters': ['extra'],
    },
},

Greenlet handling

Django middleware automatically groups all greenlets spawned during request lifetime and kills the entire group in the request finalizer to avoid memory leaks.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

context_goodies-0.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

context_goodies-0.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file context_goodies-0.1.tar.gz.

File metadata

  • Download URL: context_goodies-0.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for context_goodies-0.1.tar.gz
Algorithm Hash digest
SHA256 f6886a3ecdf6cb199c28c0223b923436ef1f31386d77b626ef805359b941b126
MD5 88d028665c0656ab813dd9561e0c9fb8
BLAKE2b-256 1749fb1192a622d73d58362b20f2a410cc8650ed14d65e42dc3c56e2a8c4deef

See more details on using hashes here.

Provenance

The following attestation bundles were made for context_goodies-0.1.tar.gz:

Publisher: publish.yml on mbachry/context-goodies

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file context_goodies-0.1-py3-none-any.whl.

File metadata

  • Download URL: context_goodies-0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for context_goodies-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 486017fc321ab074c847f2013f9c4f6770523886c547e58a7670675ba0f61913
MD5 7aa853accc309ed58e29815be443d90d
BLAKE2b-256 01757ca6d716796dbd825751f9ed89736e5e15b08be6f2823759ae6d005f05a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for context_goodies-0.1-py3-none-any.whl:

Publisher: publish.yml on mbachry/context-goodies

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page