ni / ni/nimi-python

Need a way to subscribe to DriverWarning as events with a callback

Open
#2,088 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
128
Forks
110
Avg merge
5d 14h
Merged PRs (30d)
10

Description

With warnings.warn, if users have to asynchronously process driver warnings, then they need to override the warnings.showwarning function with a custom handler which would process driver warnings differently. This implies a global override, more things for users to maintain and a possibility of not handling certain other warnings in the application correctly. Would be good to have a warning event mechanism built into driver session which the users can subscribe to, by passing a callback function. This event mechanism can co-exist with the current warnings.warn. This way, users can adopt whatever approach makes sense for the application.

ie:

  • if they want to raise exceptions for warnings, then they can simply do
    warnings.simplefilter("error", DriverWarning)
  • if they want to asynchronously handle warnings without stopping the execution flow, then they can do
    session.warning_event.subscribe(driverwarninghandler(DriverWarning)) and define
def driverwarninghandler(DriverWarning):
    <log to file, set a flag, push to a queue, raise few warnings and ignore others, etc>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the driver session's existing DriverWarning and warnings.warn handling; the issue does not name specific files or tests. Define the callback subscription behavior and verify that asynchronous handling can coexist with the current warning mechanism.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.